]> git.localhorst.tv Git - alttp.git/blobdiff - app/Http/Controllers/RoundController.php
basic result display
[alttp.git] / app / Http / Controllers / RoundController.php
index a6754ed6474da595069316247d38e5055fcdafbf..10e4d14857fd45000863df2fab536583a8404c6e 100644 (file)
@@ -2,9 +2,25 @@
 
 namespace App\Http\Controllers;
 
+use App\Models\Round;
+use App\Models\Tournament;
 use Illuminate\Http\Request;
 
 class RoundController extends Controller
 {
-       //
+
+       public function create(Request $request) {
+               $validatedData = $request->validate([
+                       'tournament_id' => 'required|exists:App\\Models\\Tournament,id',
+               ]);
+               $tournament = Tournament::findOrFail($validatedData['tournament_id']);
+               $this->authorize('addRound', $tournament);
+
+               $round = Round::create([
+                       'tournament_id' => $validatedData['tournament_id'],
+               ]);
+
+               return $round->toJson();
+       }
+
 }