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();
+ }
+
}