]> git.localhorst.tv Git - alttp.git/blob - app/Models/Channel.php
255b52cef3537ceecfb14ac8a354b5f37af81fee
[alttp.git] / app / Models / Channel.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 Channel extends Model
9 {
10         use HasFactory;
11
12         public function getCurrentEpisode() {
13                 return $this->episodes()
14                         ->where('start', '<', now()->subMinutes(10))
15                         ->orderBy('start', 'DESC')
16                         ->first();
17         }
18
19         public function crews() {
20                 return $this->hasMany(ChannelCrew::class);
21         }
22
23         public function episodes() {
24                 return $this->belongsToMany(Episode::class)
25                         ->using(Restream::class)
26                         ->withPivot('accept_comms', 'accept_tracker');
27         }
28
29         public function organization() {
30                 return $this->belongsTo(Organization::class);
31         }
32
33         protected $casts = [
34                 'chat' => 'boolean',
35                 'chat_commands' => 'array',
36                 'languages' => 'array',
37                 'join' => 'boolean',
38         ];
39
40         protected $hidden = [
41                 'created_at',
42                 'ext_id',
43                 'updated_at',
44         ];
45
46 }