]> git.localhorst.tv Git - alttp.git/blob - app/Models/Channel.php
chat bot settings
[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                 'chat_settings' => 'array',
37                 'languages' => 'array',
38                 'join' => 'boolean',
39         ];
40
41         protected $hidden = [
42                 'created_at',
43                 'ext_id',
44                 'updated_at',
45         ];
46
47 }