X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FModels%2FEpisode.php;h=4b8a96a53e2061f527db4d88d089ac411f90e1d9;hb=abdc2ea1ade1fb12ceacc28660890750e69ae36f;hp=b4a4ec824ea3f3ccf13fc2b74d7e6e12755fece4;hpb=071885a30f24b980699b337d9cdb65952f8c6c42;p=alttp.git diff --git a/app/Models/Episode.php b/app/Models/Episode.php index b4a4ec8..4b8a96a 100644 --- a/app/Models/Episode.php +++ b/app/Models/Episode.php @@ -10,6 +10,24 @@ class Episode extends Model use HasFactory; + public function channels() { + return $this->belongsToMany(Channel::class) + ->using(Restream::class) + ->withPivot('accept_comms', 'accept_tracker'); + } + + public function crew() { + return $this->hasMany(EpisodeCrew::class); + } + + public function confirmedCrew() { + return $this->crew()->where('confirmed', true); + } + + public function confirmedCrewOfChannel(Channel $channel) { + return $this->confirmedCrew()->where('channel_id', '=', $channel->id); + } + public function event() { return $this->belongsTo(Event::class); } @@ -20,6 +38,12 @@ class Episode extends Model protected $casts = [ 'confirmed' => 'boolean', + 'start' => 'datetime', + ]; + + protected $hidden = [ + 'created_at', + 'updated_at', ]; }