X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FHttp%2FControllers%2FRoundController.php;h=2b6c617acfbaa03d93df72544f4881d2036eb812;hb=4f4b2fd64141cbbff953881e2705602a00b85df5;hp=d616b861b3d0edb8c22d99679ae4f56614d1a079;hpb=df75af8d30ceb44724280829b948dd01e86de07b;p=alttp.git diff --git a/app/Http/Controllers/RoundController.php b/app/Http/Controllers/RoundController.php index d616b86..2b6c617 100644 --- a/app/Http/Controllers/RoundController.php +++ b/app/Http/Controllers/RoundController.php @@ -22,6 +22,7 @@ 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'], @@ -38,6 +39,31 @@ class RoundController extends Controller return $round->toJson(); } + public function update(Request $request, Round $round) { + $this->authorize('update', $round); + + $validatedData = $request->validate([ + 'seed' => 'url', + 'title' => 'string', + ]); + + $round->seed = $validatedData['seed']; + $round->title = $validatedData['title']; + $round->update(); + + Protocol::roundEdited( + $round->tournament, + $round, + $request->user(), + ); + + RoundChanged::dispatch($round); + + $round->load(['results', 'results.user']); + + return $round->toJson(); + } + public function setSeed(Request $request, Round $round) { $this->authorize('setSeed', $round); @@ -56,7 +82,7 @@ class RoundController extends Controller RoundChanged::dispatch($round); - $round->load('results'); + $round->load(['results', 'results.user']); return $round->toJson(); } @@ -75,7 +101,7 @@ class RoundController extends Controller RoundChanged::dispatch($round); - $round->load('results'); + $round->load(['results', 'results.user']); return $round->toJson(); } @@ -94,7 +120,7 @@ class RoundController extends Controller RoundChanged::dispatch($round); - $round->load('results'); + $round->load(['results', 'results.user']); return $round->toJson(); }