mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
basic filter D:
This commit is contained in:
@@ -28,14 +28,31 @@ class GameController extends Controller
|
||||
// Get search parameters
|
||||
$search = trim($queryParams['search'] ?? '');
|
||||
|
||||
// Get filter parameters
|
||||
$genres = $queryParams['genres'] ?? [];
|
||||
if (!is_array($genres)) {
|
||||
$genres = [$genres];
|
||||
}
|
||||
$genres = array_filter($genres);
|
||||
|
||||
$platforms = $queryParams['platforms'] ?? [];
|
||||
if (!is_array($platforms)) {
|
||||
$platforms = [$platforms];
|
||||
}
|
||||
$platforms = array_filter($platforms);
|
||||
|
||||
// Get view mode
|
||||
$viewMode = $queryParams['view'] ?? 'grid'; // grid, list, covers
|
||||
|
||||
// Get games with pagination and search
|
||||
$games = Game::getGroupedGamesWithPagination($this->pdo, $page, $perPage, $search);
|
||||
// Get games with pagination and filters
|
||||
$games = Game::getGroupedGamesWithPagination($this->pdo, $page, $perPage, $search, $genres, $platforms);
|
||||
|
||||
// Get total count for pagination
|
||||
$totalCount = Game::getTotalCount($this->pdo, $search);
|
||||
$totalCount = Game::getTotalCount($this->pdo, $search, $genres, $platforms);
|
||||
|
||||
// Get available filter options
|
||||
$availableGenres = Game::getAvailableGenres($this->pdo);
|
||||
$availablePlatforms = Game::getAvailablePlatforms($this->pdo);
|
||||
|
||||
// Calculate pagination info
|
||||
$totalPages = ceil($totalCount / $perPage);
|
||||
@@ -57,7 +74,15 @@ class GameController extends Controller
|
||||
],
|
||||
'search' => $search,
|
||||
'view_mode' => $viewMode,
|
||||
'view_modes' => ['grid', 'list', 'covers']
|
||||
'view_modes' => ['grid', 'list', 'covers'],
|
||||
'filters' => [
|
||||
'genres' => $genres,
|
||||
'platforms' => $platforms
|
||||
],
|
||||
'available_filters' => [
|
||||
'genres' => $availableGenres,
|
||||
'platforms' => $availablePlatforms
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user