]> git.localhorst.tv Git - alttp.git/blobdiff - app/Http/Controllers/RoundController.php
round titles
[alttp.git] / app / Http / Controllers / RoundController.php
index 4938b3a04a0bac61c31ccd2d2ba49dd604d2209c..2b6c617acfbaa03d93df72544f4881d2036eb812 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'],
                ]);
 
@@ -37,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);
 
@@ -55,7 +82,7 @@ class RoundController extends Controller
 
                RoundChanged::dispatch($round);
 
-               $round->load('results');
+               $round->load(['results', 'results.user']);
 
                return $round->toJson();
        }
@@ -74,7 +101,7 @@ class RoundController extends Controller
 
                RoundChanged::dispatch($round);
 
-               $round->load('results');
+               $round->load(['results', 'results.user']);
 
                return $round->toJson();
        }
@@ -93,7 +120,7 @@ class RoundController extends Controller
 
                RoundChanged::dispatch($round);
 
-               $round->load('results');
+               $round->load(['results', 'results.user']);
 
                return $round->toJson();
        }