]> git.localhorst.tv Git - alttp.git/blobdiff - app/Http/Controllers/TournamentController.php
option to hide round numbers
[alttp.git] / app / Http / Controllers / TournamentController.php
index f53dad4b644e5aee03481c5e670424ea6e8fe1ac..2dc7e51a84ae104597626dd05950b4383c55e873 100644 (file)
@@ -102,6 +102,22 @@ class TournamentController extends Controller
                return $rounds->toArray();
        }
 
+       public function settings(Request $request, Tournament $tournament) {
+               $this->authorize('update', $tournament);
+               $validatedData = $request->validate([
+                       'show_numbers' => 'boolean|nullable',
+               ]);
+               if (array_key_exists('show_numbers', $validatedData)) {
+                       $tournament->show_numbers = $validatedData['show_numbers'];
+               }
+               $tournament->save();
+               if ($tournament->wasChanged()) {
+                       TournamentChanged::dispatch($tournament);
+                       Protocol::tournamentSettings($tournament, $request->user());
+               }
+               return $tournament->toJson();
+       }
+
        public function open(Request $request, Tournament $tournament) {
                $this->authorize('update', $tournament);
                $tournament->accept_applications = true;