$tournament = Tournament::findOrFail($validatedData['tournament_id']);
$this->authorize('addRound', $tournament);
+ $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'],
]);
RoundChanged::dispatch($round);
- $round->load('results');
+ $round->load(['results', 'results.user']);
+
+ 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', 'results.user']);
+
+ 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', 'results.user']);
return $round->toJson();
}