3 namespace App\Policies;
7 use Illuminate\Auth\Access\HandlesAuthorization;
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)
25 * Determine whether the user can view the model.
27 * @param \App\Models\User $user
28 * @param \App\Models\Round $round
29 * @return \Illuminate\Auth\Access\Response|bool
31 public function view(User $user, Round $round)
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\Round $round
52 * @return \Illuminate\Auth\Access\Response|bool
54 public function update(User $user, Round $round)
56 return !$round->tournament->locked && $user->isTournamentAdmin($round->tournament);
60 * Determine whether the user can delete the model.
62 * @param \App\Models\User $user
63 * @param \App\Models\Round $round
64 * @return \Illuminate\Auth\Access\Response|bool
66 public function delete(User $user, Round $round)
72 * Determine whether the user can restore the model.
74 * @param \App\Models\User $user
75 * @param \App\Models\Round $round
76 * @return \Illuminate\Auth\Access\Response|bool
78 public function restore(User $user, Round $round)
84 * Determine whether the user can permanently delete the model.
86 * @param \App\Models\User $user
87 * @param \App\Models\Round $round
88 * @return \Illuminate\Auth\Access\Response|bool
90 public function forceDelete(User $user, Round $round)
96 * Determine whether the user can see the results for this round.
98 * @param \App\Models\User $user
99 * @param \App\Models\Round $round
100 * @return \Illuminate\Auth\Access\Response|bool
102 public function seeResults(?User $user, Round $round)
106 ($user && $user->hasFinished($round)) ||
107 ($user && $user->isTournamentMonitor($round->tournament)) ||
108 $round->isComplete();
112 * Determine whether the user can set the seed for this round.
114 * @param \App\Models\User $user
115 * @param \App\Models\Round $round
116 * @return \Illuminate\Auth\Access\Response|bool
118 public function setSeed(User $user, Round $round)
120 return !$round->locked && ($user->isRunner($round->tournament) || $user->isTournamentAdmin($round->tournament));
124 * Determine whether the user can lock this round.
126 * @param \App\Models\User $user
127 * @param \App\Models\Round $round
128 * @return \Illuminate\Auth\Access\Response|bool
130 public function lock(User $user, Round $round)
132 return !$round->tournament->locked && ($user->isTournamentAdmin($round->tournament));
136 * Determine whether the user can unlock this round.
138 * @param \App\Models\User $user
139 * @param \App\Models\Round $round
140 * @return \Illuminate\Auth\Access\Response|bool
142 public function unlock(User $user, Round $round)
144 return $this->lock($user, $round);