]> git.localhorst.tv Git - alttp.git/blobdiff - app/Models/Channel.php
first simple twitch commands
[alttp.git] / app / Models / Channel.php
index d68ba5884888838271dbceac3e9ab8b3a3314c4f..0536aef36e9638ace6387d2f3fbba3f50c2bcace 100644 (file)
@@ -9,11 +9,25 @@ class Channel extends Model
 {
        use HasFactory;
 
+       public function getCurrentEpisode() {
+               return $this->episodes()
+                       ->where('start', '<', now()->subMinutes(10))
+                       ->orderBy('start', 'DESC')
+                       ->first();
+       }
+
+       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_commands' => 'array',
                'languages' => 'array',
        ];