]> git.localhorst.tv Git - alttp.git/blob - app/Models/Channel.php
first simple twitch commands
[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 episodes() {
20                 return $this->belongsToMany(Episode::class)
21                         ->using(Restream::class)
22                         ->withPivot('accept_comms', 'accept_tracker');
23         }
24
25         public function organization() {
26                 return $this->belongsTo(Organization::class);
27         }
28
29         protected $casts = [
30                 'chat_commands' => 'array',
31                 'languages' => 'array',
32         ];
33
34         protected $hidden = [
35                 'created_at',
36                 'ext_id',
37                 'updated_at',
38         ];
39
40 }