]> git.localhorst.tv Git - alttp.git/blobdiff - app/Policies/TournamentPolicy.php
respond to whispers
[alttp.git] / app / Policies / TournamentPolicy.php
index 5942b7f7979c8ff215275b9e6a83d6853e8624b7..f58eee76dc12be424ddf5c26f89d49a57a80d676 100644 (file)
@@ -53,7 +53,7 @@ class TournamentPolicy
         */
        public function update(User $user, Tournament $tournament)
        {
-               return $user->isTournamentAdmin($tournament);
+               return $user->isAdmin() || $user->isTournamentAdmin($tournament);
        }
 
        /**
@@ -104,6 +104,18 @@ class TournamentPolicy
                return !$tournament->locked && ($user->isRunner($tournament) || $user->isTournamentAdmin($tournament));
        }
 
+       /**
+        * Determine whether the user can apply to participate.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Tournament  $tournament
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function apply(User $user, Tournament $tournament)
+       {
+               return $tournament->accept_applications && !$user->isRunner($tournament) && !$user->isApplicant($tournament);
+       }
+
        /**
         * Determine whether the user can view the tournament protocol.
         *