Add fn for prepared (post link) Data injection

main
Alex 2 years ago
parent 82c40c6c9b
commit 8ab13024c7

@ -11,10 +11,10 @@ use Illuminate\Support\Str;
class IGDBController extends Controller class IGDBController extends Controller
{ {
public static function getGameDetails(string $slug) public static function getGameDetails(string $slug)
{ {// TODO Weiter bauen und weiter Details für Link aufbröseln
$game = Http::withHeaders(config('services.igdb'))->withBody( $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; "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}\";", where slug=\"{$slug}\";",
"text/plain" "text/plain"
)->post('https://api.igdb.com/v4/games') )->post('https://api.igdb.com/v4/games')
->json(); ->json();
@ -25,6 +25,19 @@ class IGDBController extends Controller
return $game[0]; 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) { public static function searchGameByName(string $name) {

Loading…
Cancel
Save