build: initialize RetroHub with Laravel, Inertia, Vue, and Horizon
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use App\Features\Consoles\Console;
|
||||
use App\Features\Games\Game;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::middleware('auth:sanctum')->group(function () {
|
||||
Route::get('/consoles', function () {
|
||||
return response()->json(Console::withCount('games')->orderBy('name')->get());
|
||||
});
|
||||
|
||||
Route::get('/games', function () {
|
||||
$query = Game::with('console');
|
||||
|
||||
if (request()->has('console')) {
|
||||
$query->whereHas('console', function ($q) {
|
||||
$q->where('slug', request()->console);
|
||||
});
|
||||
}
|
||||
|
||||
if (request()->has('search')) {
|
||||
$query->where('title', 'like', '%'.request()->search.'%');
|
||||
}
|
||||
|
||||
return response()->json($query->orderBy('title')->paginate(24));
|
||||
});
|
||||
|
||||
Route::get('/games/{game}', function (Game $game) {
|
||||
$game->load(['console', 'romFiles']);
|
||||
|
||||
return response()->json($game);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user