X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FHttp%2FControllers%2FRoundController.php;h=d616b861b3d0edb8c22d99679ae4f56614d1a079;hb=df75af8d30ceb44724280829b948dd01e86de07b;hp=d884d544bb22f5bd728e5e2f24859ab81ea6647e;hpb=a907ef7c6676fef11f42933b2d79bdd496b20122;p=alttp.git diff --git a/app/Http/Controllers/RoundController.php b/app/Http/Controllers/RoundController.php index d884d54..d616b86 100644 --- a/app/Http/Controllers/RoundController.php +++ b/app/Http/Controllers/RoundController.php @@ -19,7 +19,11 @@ class RoundController extends Controller $tournament = Tournament::findOrFail($validatedData['tournament_id']); $this->authorize('addRound', $tournament); + $tournament->loadMax('rounds', 'number'); + $round = Round::create([ + 'number' => intval($tournament->rounds_max_number) + 1, + 'no_record' => $tournament->no_record, 'tournament_id' => $validatedData['tournament_id'], ]); @@ -57,4 +61,42 @@ class RoundController extends Controller 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'); + + 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'); + + return $round->toJson(); + } + }