37 lines
1.6 KiB
PHP
37 lines
1.6 KiB
PHP
<?php
|
|
|
|
use App\Http\Controllers\CompetitionController;
|
|
use App\Http\Controllers\TournamentController;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Route;
|
|
use Inertia\Inertia;
|
|
|
|
Route::get('/', function () {
|
|
// get user if it exists
|
|
$user = Auth::user();
|
|
$userTournaments = [];
|
|
if ($user) {
|
|
$userTournaments = Inertia::defer(fn() => CompetitionController::getUser($user, 0, 10));
|
|
}
|
|
return Inertia::render('Home', [
|
|
'publicTournaments' => Inertia::defer(fn() => CompetitionController::getPublics(1, 10)),
|
|
'userTournaments' => $userTournaments,
|
|
]);
|
|
})->name('home');
|
|
|
|
Route::get('dashboard', function () {
|
|
return Inertia::render('Dashboard');
|
|
})->middleware(['auth', 'verified'])->name('dashboard');
|
|
|
|
// Tournament routes
|
|
Route::middleware(['auth', 'verified'])->group(function () {
|
|
Route::get('tournaments/create', [TournamentController::class, 'create'])->name('tournaments.create');
|
|
Route::post('tournaments', [TournamentController::class, 'store'])->name('tournaments.store');
|
|
Route::get('tournaments/{tournament}', [TournamentController::class, 'show'])->name('tournaments.show');
|
|
Route::get('tournaments/{tournament}/edit', [TournamentController::class, 'edit'])->name('tournaments.edit');
|
|
Route::put('tournaments/{tournament}', [TournamentController::class, 'update'])->name('tournaments.update');
|
|
Route::delete('tournaments/{tournament}', [TournamentController::class, 'destroy'])->name('tournaments.destroy');
|
|
});
|
|
|
|
require __DIR__ . '/settings.php';
|
|
require __DIR__ . '/auth.php';
|