Added corrections to user profile and admin match and game history
This commit is contained in:
+6
-31
@@ -46,37 +46,8 @@ Route::prefix('v1')->group(function () {
|
||||
});
|
||||
|
||||
Route::prefix('games')->group(function () {
|
||||
//Host a new multiplayer game - MUST come before resource routes
|
||||
Route::post('host', function (\Illuminate\Http\Request $request) {
|
||||
$request->validate([
|
||||
'type' => 'required|in:3,9'
|
||||
]);
|
||||
|
||||
$game = \App\Models\Game::create([
|
||||
'type' => $request->type,
|
||||
'status' => 'Pending',
|
||||
'player1_user_id' => $request->user()->id,
|
||||
'player2_user_id' => 1, // Ghost player
|
||||
'began_at' => now(),
|
||||
]);
|
||||
|
||||
return response()->json($game);
|
||||
});
|
||||
|
||||
// List open games (available to join)
|
||||
Route::get('open', function (\Illuminate\Http\Request $request) {
|
||||
$type = $request->query('type', '9');
|
||||
|
||||
$games = \App\Models\Game::where('status', 'Pending')
|
||||
->where('player2_user_id', 1) // Only games waiting for a second player
|
||||
->where('type', $type)
|
||||
->with('player1') // Load player1 relationship
|
||||
->orderBy('began_at', 'asc')
|
||||
->paginate(10);
|
||||
|
||||
return response()->json($games);
|
||||
});
|
||||
|
||||
Route::post('host', [GameController::class, 'host']);
|
||||
Route::get('open', [GameController::class, 'open']);
|
||||
Route::get('/', [GameController::class, 'index']);
|
||||
Route::get('/{game}', [GameController::class, 'show']);
|
||||
Route::post('/', [GameController::class, 'store']);
|
||||
@@ -89,6 +60,8 @@ Route::prefix('v1')->group(function () {
|
||||
Route::prefix('matches')->group(function () {
|
||||
Route::apiResource('/', MatchController::class)->parameters(['' => 'match']);
|
||||
Route::post('/{match}/join', [MatchController::class, 'join']);
|
||||
Route::post('host', [MatchController::class, 'host']); // <--- NOVA
|
||||
Route::get('open', [MatchController::class, 'open']);
|
||||
});
|
||||
|
||||
// Admin Routes
|
||||
@@ -97,6 +70,8 @@ Route::prefix('v1')->group(function () {
|
||||
->group(function () {
|
||||
Route::get('/statistics', [StatisticsController::class, 'getAdminStats']);
|
||||
Route::get('/transactions', [TransactionController::class, 'index']);
|
||||
Route::get('/games', [GameController::class, 'index']);
|
||||
Route::get('/matches', [MatchController::class, 'index']);
|
||||
Route::prefix('users')->group(function () {
|
||||
Route::get('/', [UserController::class, 'index']);
|
||||
Route::post('/', [UserController::class, 'store']);
|
||||
|
||||
Reference in New Issue
Block a user