X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=app%2FModels%2FChannel.php;h=255b52cef3537ceecfb14ac8a354b5f37af81fee;hb=85879ea0c27ce6506919e2c083a139c470c0952c;hp=d68ba5884888838271dbceac3e9ab8b3a3314c4f;hpb=15132749249f6418fd5695547b5c323a0ad10939;p=alttp.git diff --git a/app/Models/Channel.php b/app/Models/Channel.php index d68ba58..255b52c 100644 --- a/app/Models/Channel.php +++ b/app/Models/Channel.php @@ -9,12 +9,32 @@ class Channel extends Model { use HasFactory; + public function getCurrentEpisode() { + return $this->episodes() + ->where('start', '<', now()->subMinutes(10)) + ->orderBy('start', 'DESC') + ->first(); + } + + public function crews() { + return $this->hasMany(ChannelCrew::class); + } + + public function episodes() { + return $this->belongsToMany(Episode::class) + ->using(Restream::class) + ->withPivot('accept_comms', 'accept_tracker'); + } + public function organization() { return $this->belongsTo(Organization::class); } protected $casts = [ + 'chat' => 'boolean', + 'chat_commands' => 'array', 'languages' => 'array', + 'join' => 'boolean', ]; protected $hidden = [