3 namespace App\Policies;
5 use App\Models\DiscordGuild;
7 use Illuminate\Auth\Access\HandlesAuthorization;
9 class DiscordGuildPolicy
11 use HandlesAuthorization;
14 * Determine whether the user can view any models.
16 * @param \App\Models\User $user
17 * @return \Illuminate\Auth\Access\Response|bool
19 public function viewAny(User $user)
21 return $user->isAdmin();
25 * Determine whether the user can view the model.
27 * @param \App\Models\User $user
28 * @param \App\Models\DiscordGuild $discordGuild
29 * @return \Illuminate\Auth\Access\Response|bool
31 public function view(User $user, DiscordGuild $discordGuild)
33 return $user->isAdmin() || $discordGuild->owner == $user->id;
37 * Determine whether the user can create models.
39 * @param \App\Models\User $user
40 * @return \Illuminate\Auth\Access\Response|bool
42 public function create(User $user)
48 * Determine whether the user can update the model.
50 * @param \App\Models\User $user
51 * @param \App\Models\DiscordGuild $discordGuild
52 * @return \Illuminate\Auth\Access\Response|bool
54 public function update(User $user, DiscordGuild $discordGuild)
60 * Determine whether the user can delete the model.
62 * @param \App\Models\User $user
63 * @param \App\Models\DiscordGuild $discordGuild
64 * @return \Illuminate\Auth\Access\Response|bool
66 public function delete(User $user, DiscordGuild $discordGuild)
72 * Determine whether the user can restore the model.
74 * @param \App\Models\User $user
75 * @param \App\Models\DiscordGuild $discordGuild
76 * @return \Illuminate\Auth\Access\Response|bool
78 public function restore(User $user, DiscordGuild $discordGuild)
84 * Determine whether the user can permanently delete the model.
86 * @param \App\Models\User $user
87 * @param \App\Models\DiscordGuild $discordGuild
88 * @return \Illuminate\Auth\Access\Response|bool
90 public function forceDelete(User $user, DiscordGuild $discordGuild)