X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=app%2FHttp%2FControllers%2FRoundController.php;h=6d31e9020897ee8968d7b2ce5040197a68368b86;hb=c5b15dc5518c627daa4f02f653ff900e4fe13db7;hp=596628d072da19ceae60e2c5190d8c2e6c23404d;hpb=9160186db0ea1b0da0edfec49cb3d99ead213bc4;p=alttp.git diff --git a/app/Http/Controllers/RoundController.php b/app/Http/Controllers/RoundController.php index 596628d..6d31e90 100644 --- a/app/Http/Controllers/RoundController.php +++ b/app/Http/Controllers/RoundController.php @@ -39,6 +39,36 @@ class RoundController extends Controller return $round->toJson(); } + public function update(Request $request, Round $round) { + $this->authorize('update', $round); + + $validatedData = $request->validate([ + 'code' => 'array', + 'code.*' => 'string', + 'rolled_by' => 'nullable|exists:App\\Models\\User,id', + 'seed' => 'url', + 'title' => 'string', + ]); + + $round->code = array_filter($validatedData['code']); + $round->rolled_by = $validatedData['rolled_by']; + $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); @@ -57,7 +87,7 @@ class RoundController extends Controller RoundChanged::dispatch($round); - $round->load('results'); + $round->load(['results', 'results.user']); return $round->toJson(); } @@ -76,7 +106,7 @@ class RoundController extends Controller RoundChanged::dispatch($round); - $round->load('results'); + $round->load(['results', 'results.user']); return $round->toJson(); } @@ -95,7 +125,7 @@ class RoundController extends Controller RoundChanged::dispatch($round); - $round->load('results'); + $round->load(['results', 'results.user']); return $round->toJson(); }