X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FPolicies%2FChannelPolicy.php;fp=app%2FPolicies%2FChannelPolicy.php;h=03abdff04f6564278e5d1fe2efccf313bc61e8a4;hb=638802eaf20d636c16d7ce337ace508708705f2c;hp=0000000000000000000000000000000000000000;hpb=ed531959edb865805c828f2c318146c43f6e581b;p=alttp.git diff --git a/app/Policies/ChannelPolicy.php b/app/Policies/ChannelPolicy.php new file mode 100644 index 0000000..03abdff --- /dev/null +++ b/app/Policies/ChannelPolicy.php @@ -0,0 +1,123 @@ +event->visible; + } + + /** + * Determine whether the user can create models. + * + * @param \App\Models\User $user + * @return \Illuminate\Auth\Access\Response|bool + */ + public function create(User $user) + { + return $user->isAdmin(); + } + + /** + * Determine whether the user can update the model. + * + * @param \App\Models\User $user + * @param \App\Models\Channel $channel + * @return \Illuminate\Auth\Access\Response|bool + */ + public function update(User $user, Channel $channel) + { + return $user->isAdmin(); + } + + /** + * Determine whether the user can delete the model. + * + * @param \App\Models\User $user + * @param \App\Models\Channel $channel + * @return \Illuminate\Auth\Access\Response|bool + */ + public function delete(User $user, Channel $channel) + { + return false; + } + + /** + * Determine whether the user can restore the model. + * + * @param \App\Models\User $user + * @param \App\Models\Channel $channel + * @return \Illuminate\Auth\Access\Response|bool + */ + public function restore(User $user, Channel $channel) + { + return false; + } + + /** + * Determine whether the user can permanently delete the model. + * + * @param \App\Models\User $user + * @param \App\Models\Channel $channel + * @return \Illuminate\Auth\Access\Response|bool + */ + public function forceDelete(User $user, Channel $channel) + { + return false; + } + + /** + * Determine whether the user can add episodes to the channel. + * + * @param \App\Models\User $user + * @param \App\Models\Channel $channel + * @return \Illuminate\Auth\Access\Response|bool + */ + public function addEpisode(User $user, Channel $channel) { + return $user->channel_crews() + ->where('role', '=', 'admin') + ->where('channel_id', '=', $channel->id) + ->count() > 0; + } + + /** + * Determine whether the user can remove episodes from the channel. + * + * @param \App\Models\User $user + * @param \App\Models\Channel $channel + * @return \Illuminate\Auth\Access\Response|bool + */ + public function removeEpisode(User $user, Channel $channel) { + return $user->channel_crews() + ->where('role', '=', 'admin') + ->where('channel_id', '=', $channel->id) + ->count() > 0; + } + +}