3 namespace App\Policies;
5 use App\Models\Application;
7 use Illuminate\Auth\Access\HandlesAuthorization;
9 class ApplicationPolicy
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\Application $application
29 * @return \Illuminate\Auth\Access\Response|bool
31 public function view(User $user, Application $application)
33 return $user->isAdmin()
34 || $user->isTournamentAdmin($application->tournament)
35 || $user->id == $application->user->id;
39 * Determine whether the user can create models.
41 * @param \App\Models\User $user
42 * @return \Illuminate\Auth\Access\Response|bool
44 public function create(User $user)
50 * Determine whether the user can update the model.
52 * @param \App\Models\User $user
53 * @param \App\Models\Application $application
54 * @return \Illuminate\Auth\Access\Response|bool
56 public function update(User $user, Application $application)
62 * Determine whether the user can delete the model.
64 * @param \App\Models\User $user
65 * @param \App\Models\Application $application
66 * @return \Illuminate\Auth\Access\Response|bool
68 public function delete(User $user, Application $application)
74 * Determine whether the user can restore the model.
76 * @param \App\Models\User $user
77 * @param \App\Models\Application $application
78 * @return \Illuminate\Auth\Access\Response|bool
80 public function restore(User $user, Application $application)
86 * Determine whether the user can permanently delete the model.
88 * @param \App\Models\User $user
89 * @param \App\Models\Application $application
90 * @return \Illuminate\Auth\Access\Response|bool
92 public function forceDelete(User $user, Application $application)
98 * Determine whether the user can accept the application.
100 * @param \App\Models\User $user
101 * @param \App\Models\Application $application
102 * @return \Illuminate\Auth\Access\Response|bool
104 public function accept(User $user, Application $application)
106 return $user->isAdmin()
107 || $user->isTournamentAdmin($application->tournament);
111 * Determine whether the user can accept the application.
113 * @param \App\Models\User $user
114 * @param \App\Models\Application $application
115 * @return \Illuminate\Auth\Access\Response|bool
117 public function reject(User $user, Application $application)
119 return $user->isAdmin()
120 || $user->isTournamentAdmin($application->tournament);