|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
|
use Illuminate\Support\Carbon;
|
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
|
|
|
|
class IGDBController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public static function getGameDetails(string $slug)
|
|
|
|
|
{
|
|
|
|
|
$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}\";",
|
|
|
|
|
"text/plain"
|
|
|
|
|
)->post('https://api.igdb.com/v4/games')
|
|
|
|
|
->json();
|
|
|
|
|
|
|
|
|
|
abort_if(!$game, 404);
|
|
|
|
|
#dd($game);
|
|
|
|
|
|
|
|
|
|
return $game[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function searchGameByName(string $name) {
|
|
|
|
|
$response = Http::withHeaders(config('services.igdb'))
|
|
|
|
|
->withBody(
|
|
|
|
|
"search \"{$name}\"; 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;",
|
|
|
|
|
"text/plain"
|
|
|
|
|
)
|
|
|
|
|
->post('https://api.igdb.com/v4/games')
|
|
|
|
|
->json();
|
|
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function searchGameBySlug(string $slug)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$game_list = 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}\";",
|
|
|
|
|
"text/plain"
|
|
|
|
|
)->post('https://api.igdb.com/v4/games')
|
|
|
|
|
->json();
|
|
|
|
|
|
|
|
|
|
abort_if(!$game, 404);
|
|
|
|
|
#dd($game);
|
|
|
|
|
|
|
|
|
|
return $game[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function getAgeRatingData()
|
|
|
|
|
{
|
|
|
|
|
/* *Note* Nullable (einige Felder sind nicht bei allen Eintr<74>gen gesetzt)
|
|
|
|
|
field type description
|
|
|
|
|
category Category Enum The organization that has issued a specific rating
|
|
|
|
|
checksum uuid Hash of the object
|
|
|
|
|
content_descriptions Array of Age Rating Content Description IDs
|
|
|
|
|
rating Rating Enum The title of an age rating
|
|
|
|
|
rating_cover_url String The url for the image of a age rating
|
|
|
|
|
synopsis String A free text motivating a rating
|
|
|
|
|
*/
|
|
|
|
|
$game_list = Http::withHeaders(config('services.igdb'))->withBody(
|
|
|
|
|
"fields *, content_descriptions.* , rating_cover_url ;",
|
|
|
|
|
"text/plain"
|
|
|
|
|
)->post('https://api.igdb.com/v4/age_ratings')
|
|
|
|
|
->json();
|
|
|
|
|
|
|
|
|
|
abort_if(!$game, 404);
|
|
|
|
|
#dd($game);
|
|
|
|
|
|
|
|
|
|
return $game[0];
|
|
|
|
|
}
|
|
|
|
|
}
|