]> git.localhorst.tv Git - alttp.git/blobdiff - app/Policies/EpisodePolicy.php
basic channel crew
[alttp.git] / app / Policies / EpisodePolicy.php
index 18988cfa2918e0e967db4e37ddc2d7c8b5347f34..6be9ad02ec02855cf5da87a7945e19775fdd0a2b 100644 (file)
@@ -91,4 +91,33 @@ class EpisodePolicy
        {
                return false;
        }
+
+       /**
+        * Determine whether the user can add restreams for the episode.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Episode  $episode
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function addRestream(User $user, Episode $episode) {
+               return $user->channel_crews()
+                         ->where('role', '=', 'admin')
+                         ->whereNotIn('channel_id', $episode->channels->pluck('id'))
+                         ->count() > 0;
+       }
+
+       /**
+        * Determine whether the user can remove restreams from the episode.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Episode  $episode
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function removeRestream(User $user, Episode $episode) {
+               return $user->channel_crews()
+                         ->where('role', '=', 'admin')
+                         ->whereIn('channel_id', $episode->channels->pluck('id'))
+                         ->count() > 0;
+       }
+
 }