]> git.localhorst.tv Git - alttp.git/blob - app/Models/Episode.php
better chat filters
[alttp.git] / app / Models / Episode.php
1 <?php
2
3 namespace App\Models;
4
5 use Illuminate\Database\Eloquent\Factories\HasFactory;
6 use Illuminate\Database\Eloquent\Model;
7
8 class Episode extends Model
9 {
10
11         use HasFactory;
12
13         public function channels() {
14                 return $this->belongsToMany(Channel::class)
15                         ->using(Restream::class)
16                         ->withPivot('accept_comms', 'accept_tracker');
17         }
18
19         public function crew() {
20                 return $this->hasMany(EpisodeCrew::class);
21         }
22
23         public function confirmedCrew() {
24                 return $this->crew()->where('confirmed', true);
25         }
26
27         public function confirmedCrewOfChannel(Channel $channel) {
28                 return $this->confirmedCrew()->where('channel_id', '=', $channel->id);
29         }
30
31         public function event() {
32                 return $this->belongsTo(Event::class);
33         }
34
35         public function players() {
36                 return $this->hasMany(EpisodePlayer::class);
37         }
38
39         protected $casts = [
40                 'confirmed' => 'boolean',
41                 'start' => 'datetime',
42         ];
43
44         protected $hidden = [
45                 'created_at',
46                 'updated_at',
47         ];
48
49 }