sintonia_webapp/app/Models/ShowInstances/ShowInstances.php
2025-04-09 10:33:48 +02:00

55 lines
1.3 KiB
PHP

<?php
namespace App\Models\ShowInstances;
use App\Filters\Show\ShowInstancesFilters;
use App\Models\File;
use App\Models\Show\Show;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class ShowInstances extends Model
{
protected $table = 'cc_show_instances';
protected $dateFormat = 'c';
protected $dates = ['starts', 'ends'];
protected $fillable = [
'starts',
'ends',
'description',
'show_id',
'record',
'rebroadcast',
'time_filled',
'created',
'modified_instance',
'autoplaylist_built',
];
protected $casts = [
'created' => 'timestamp',
'last_scheduled' => 'timestamp',
'starts' => 'datetime',
'ends' => 'datetime',
'modified_instance' => 'boolean',
'autoplaylist_built' => 'boolean',
];
public function file(): BelongsTo
{
return $this->belongsTo(File::class, 'file_id');
}
public function show(): BelongsTo
{
return $this->belongsTo(Show::class, 'show_id');
}
public function scopeSearchFilter($query, $request) {
$filters = new ShowInstancesFilters();
return $filters->apply($query, $request);
}
}