This commit is contained in:
Doar Mihai
2026-05-30 18:56:17 +03:00
parent 17a2211952
commit afc49488a9
5 changed files with 93 additions and 33 deletions
+45
View File
@@ -139,6 +139,51 @@ class IgdbService
");
}
/**
* Get games released in a given year.
*/
public function getGamesByYear(int $year, int $limit = 20, int $offset = 0): array
{
$from = mktime(0, 0, 0, 1, 1, $year);
$to = mktime(23, 59, 59, 12, 31, $year);
return $this->query('games', "
fields id,name,slug,summary,cover.image_id,first_release_date,
genres.id,genres.name,genres.slug,
platforms.id,platforms.name,platforms.slug,platforms.abbreviation,
involved_companies.company.id,involved_companies.company.name,
involved_companies.company.slug,involved_companies.developer,
involved_companies.publisher,
screenshots.image_id,
rating,rating_count;
where first_release_date >= {$from} & first_release_date <= {$to} & cover != null;
sort rating_count desc;
limit {$limit};
offset {$offset};
");
}
/**
* Get games for a given platform IGDB ID.
*/
public function getGamesByPlatform(int $platformIgdbId, int $limit = 20, int $offset = 0): array
{
return $this->query('games', "
fields id,name,slug,summary,cover.image_id,first_release_date,
genres.id,genres.name,genres.slug,
platforms.id,platforms.name,platforms.slug,platforms.abbreviation,
involved_companies.company.id,involved_companies.company.name,
involved_companies.company.slug,involved_companies.developer,
involved_companies.publisher,
screenshots.image_id,
rating,rating_count;
where platforms = [{$platformIgdbId}] & cover != null & rating != null;
sort rating_count desc;
limit {$limit};
offset {$offset};
");
}
/**
* Get games by genre.
*/