modifiche siderbar e correzioni
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
class TipologiaEvento extends Model
|
||||
{
|
||||
protected $table = 'tipologie_eventi';
|
||||
|
||||
protected $fillable = ['nome', 'descrizione', 'ordine', 'attiva'];
|
||||
|
||||
protected $casts = [
|
||||
'attiva' => 'boolean',
|
||||
'ordine' => 'integer',
|
||||
];
|
||||
|
||||
public function eventi(): HasMany
|
||||
{
|
||||
return $this->hasMany(Evento::class, 'tipo_evento', 'nome');
|
||||
}
|
||||
|
||||
public static function attive(): \Illuminate\Database\Eloquent\Collection
|
||||
{
|
||||
return static::where('attiva', true)->orderBy('ordine')->get();
|
||||
}
|
||||
|
||||
public static function opzioni(): array
|
||||
{
|
||||
return static::attive()->pluck('nome')->toArray();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user