]> git.localhorst.tv Git - alttp.git/blobdiff - app/Http/Controllers/RoundController.php
protocol chat bot messages
[alttp.git] / app / Http / Controllers / RoundController.php
index 596628d072da19ceae60e2c5190d8c2e6c23404d..8ec2b84d010eb7519f4e1da796b2e7717e8d1e01 100644 (file)
@@ -39,6 +39,38 @@ 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',
+                       'spoiler' => 'url',
+                       'title' => 'string',
+               ]);
+
+               $round->code = array_filter($validatedData['code']);
+               $round->rolled_by = $validatedData['rolled_by'];
+               $round->seed = $validatedData['seed'];
+               $round->spoiler = $validatedData['spoiler'];
+               $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 +89,7 @@ class RoundController extends Controller
 
                RoundChanged::dispatch($round);
 
-               $round->load('results');
+               $round->load(['results', 'results.user']);
 
                return $round->toJson();
        }
@@ -76,7 +108,7 @@ class RoundController extends Controller
 
                RoundChanged::dispatch($round);
 
-               $round->load('results');
+               $round->load(['results', 'results.user']);
 
                return $round->toJson();
        }
@@ -95,7 +127,7 @@ class RoundController extends Controller
 
                RoundChanged::dispatch($round);
 
-               $round->load('results');
+               $round->load(['results', 'results.user']);
 
                return $round->toJson();
        }