diff --git a/app/Http/Controllers/IGDBController.php b/app/Http/Controllers/IGDBController.php index b161d05..92ad969 100644 --- a/app/Http/Controllers/IGDBController.php +++ b/app/Http/Controllers/IGDBController.php @@ -11,10 +11,10 @@ use Illuminate\Support\Str; class IGDBController extends Controller { public static function getGameDetails(string $slug) - { + {// TODO Weiter bauen und weiter Details für Link aufbröseln $game = Http::withHeaders(config('services.igdb'))->withBody( - "fields *, name, cover.url, first_release_date, total_rating_count, platforms.abbreviation, rating, rating_count, slug, involved_companies.company.name, genres.name, aggregated_rating, summary, websites.*, videos.*, screenshots.*, similar_games.*, similar_games.cover.url, similar_games.platforms.abbreviation; - where slug=\"{$slug}\";", + "fields *,age_ratings.*, age_ratings.*, name, cover.url, first_release_date, total_rating_count, platforms.abbreviation, rating, rating_count, slug, involved_companies.company.name, genres.name, aggregated_rating, summary, websites.*, videos.*, screenshots.*, similar_games.*, similar_games.cover.url, similar_games.platforms.abbreviation; + where slug=\"{$slug}\";", "text/plain" )->post('https://api.igdb.com/v4/games') ->json(); @@ -25,6 +25,19 @@ class IGDBController extends Controller return $game[0]; } + public static function getPreparedGameDetails(string $slug) + { + $game = IGDBController::getGameDetails($slug); + $rating_ids = []; + foreach ($game['age_ratings'] as $rating){ + array_push($rating_ids, $rating['rating']); + } + $game['age_ratings'] = $rating_ids; + abort_if(!$game, 404); + #dd($game); + + return $game; + } public static function searchGameByName(string $name) {