]> git.localhorst.tv Git - alttp.git/blobdiff - app/Http/Controllers/RoundController.php
new front page
[alttp.git] / app / Http / Controllers / RoundController.php
index f7e70423f07a987689e03bc5ec15f69f64bc7da4..04e1b865ca0fb3560be7ac9231e5f998b3974897 100644 (file)
@@ -22,7 +22,9 @@ class RoundController extends Controller
                $tournament->loadMax('rounds', 'number');
 
                $round = Round::create([
+                       'game' => $tournament->game,
                        'number' => intval($tournament->rounds_max_number) + 1,
+                       'no_record' => $tournament->no_record,
                        'tournament_id' => $validatedData['tournament_id'],
                ]);
 
@@ -55,7 +57,45 @@ class RoundController extends Controller
 
                RoundChanged::dispatch($round);
 
-               $round->load('results');
+               $round->load(['results', 'results.user']);
+
+               return $round->toJson();
+       }
+
+       public function lock(Request $request, Round $round) {
+               $this->authorize('lock', $round);
+
+               $round->locked = true;
+               $round->update();
+
+               Protocol::roundLocked(
+                       $round->tournament,
+                       $round,
+                       $request->user(),
+               );
+
+               RoundChanged::dispatch($round);
+
+               $round->load(['results', 'results.user']);
+
+               return $round->toJson();
+       }
+
+       public function unlock(Request $request, Round $round) {
+               $this->authorize('unlock', $round);
+
+               $round->locked = false;
+               $round->update();
+
+               Protocol::roundUnlocked(
+                       $round->tournament,
+                       $round,
+                       $request->user(),
+               );
+
+               RoundChanged::dispatch($round);
+
+               $round->load(['results', 'results.user']);
 
                return $round->toJson();
        }