X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FPolicies%2FEpisodePolicy.php;fp=app%2FPolicies%2FEpisodePolicy.php;h=6be9ad02ec02855cf5da87a7945e19775fdd0a2b;hb=638802eaf20d636c16d7ce337ace508708705f2c;hp=18988cfa2918e0e967db4e37ddc2d7c8b5347f34;hpb=ed531959edb865805c828f2c318146c43f6e581b;p=alttp.git diff --git a/app/Policies/EpisodePolicy.php b/app/Policies/EpisodePolicy.php index 18988cf..6be9ad0 100644 --- a/app/Policies/EpisodePolicy.php +++ b/app/Policies/EpisodePolicy.php @@ -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; + } + }