]> git.localhorst.tv Git - alttp.git/blobdiff - app/Http/Controllers/TournamentController.php
tournament admin control
[alttp.git] / app / Http / Controllers / TournamentController.php
index 6ef003837c1f5b99c1d4bf25003bec42706847ea..fd9aab35d79e91bae3be78889d49885ea740df6c 100644 (file)
@@ -3,6 +3,7 @@
 namespace App\Http\Controllers;
 
 use App\Events\ApplicationAdded;
+use App\Events\TournamentChanged;
 use App\Models\Application;
 use App\Models\Protocol;
 use App\Models\Tournament;
@@ -43,4 +44,40 @@ class TournamentController extends Controller
                return $tournament->toJson();
        }
 
+       public function open(Request $request, Tournament $tournament) {
+               $this->authorize('update', $tournament);
+               $tournament->accept_applications = true;
+               $tournament->save();
+               TournamentChanged::dispatch($tournament);
+               Protocol::tournamentOpenen($tournament, $request->user());
+               return $tournament->toJson();
+       }
+
+       public function close(Request $request, Tournament $tournament) {
+               $this->authorize('update', $tournament);
+               $tournament->accept_applications = false;
+               $tournament->save();
+               TournamentChanged::dispatch($tournament);
+               Protocol::tournamentClosed($tournament, $request->user());
+               return $tournament->toJson();
+       }
+
+       public function lock(Request $request, Tournament $tournament) {
+               $this->authorize('update', $tournament);
+               $tournament->locked = true;
+               $tournament->save();
+               TournamentChanged::dispatch($tournament);
+               Protocol::tournamentLocked($tournament, $request->user());
+               return $tournament->toJson();
+       }
+
+       public function unlock(Request $request, Tournament $tournament) {
+               $this->authorize('update', $tournament);
+               $tournament->locked = false;
+               $tournament->save();
+               TournamentChanged::dispatch($tournament);
+               Protocol::tournamentUnlocked($tournament, $request->user());
+               return $tournament->toJson();
+       }
+
 }