|
|
@ -10,10 +10,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
|
|
|
|
// 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 *,age_ratings.*, age_ratings.*, alternative_names.*, name, collection.*, 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.*,aggregated_rating, age_ratings.*, alternative_names.*, name, collection.*, cover.url, first_release_date, total_rating_count, platforms.abbreviation, rating, rating_count, slug, involved_companies.company.name, keywords.*, genres.name, aggregated_rating, summary, websites.*, videos.*, screenshots.*, release_dates.*, similar_games.*, similar_games.cover.url, similar_games.platforms.abbreviation, themes.*;
|
|
|
|
where slug=\"{$slug}\";",
|
|
|
|
where slug=\"{$slug}\";",
|
|
|
|
"text/plain"
|
|
|
|
"text/plain"
|
|
|
|
)->post('https://api.igdb.com/v4/games')
|
|
|
|
)->post('https://api.igdb.com/v4/games')
|
|
|
@ -25,36 +25,64 @@ class IGDBController extends Controller
|
|
|
|
return $game[0];
|
|
|
|
return $game[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function getPreparedGameDetails(string $slug)
|
|
|
|
public static function getPreparedGameDetails(string $slug){
|
|
|
|
{
|
|
|
|
|
|
|
|
$game = IGDBController::getGameDetails($slug);
|
|
|
|
$game = IGDBController::getGameDetails($slug);
|
|
|
|
|
|
|
|
|
|
|
|
# Prep Age Rating Icons
|
|
|
|
# Prep Age Rating Icons
|
|
|
|
|
|
|
|
if (isset($game['age_ratings'])){
|
|
|
|
$game['age_ratings'] = IGDBController::prepAgeRatings($game['age_ratings']);
|
|
|
|
$game['age_ratings'] = IGDBController::prepAgeRatings($game['age_ratings']);
|
|
|
|
|
|
|
|
}
|
|
|
|
# Prep alternative names
|
|
|
|
# Prep alternative names
|
|
|
|
|
|
|
|
if (isset($game['alternative_names'])){
|
|
|
|
$game['alternative_names'] = IGDBController::prepAltName($game['alternative_names']);
|
|
|
|
$game['alternative_names'] = IGDBController::prepAltName($game['alternative_names']);
|
|
|
|
|
|
|
|
}
|
|
|
|
# Prep category
|
|
|
|
# Prep category
|
|
|
|
|
|
|
|
if (isset($game['category'])){
|
|
|
|
$game['category'] = IGDBController::prepCategory($game['category']);
|
|
|
|
$game['category'] = IGDBController::prepCategory($game['category']);
|
|
|
|
|
|
|
|
}
|
|
|
|
# Prep collection
|
|
|
|
# Prep collection
|
|
|
|
|
|
|
|
if (isset($game['collection'])){
|
|
|
|
$game['collection'] = IGDBController::prepCollection($game['collection']);
|
|
|
|
$game['collection'] = IGDBController::prepCollection($game['collection']);
|
|
|
|
|
|
|
|
}
|
|
|
|
# Prep cover_url
|
|
|
|
# Prep cover_url
|
|
|
|
|
|
|
|
if (isset($game['cover'])){
|
|
|
|
$game['cover'] = IGDBController::prepCover($game['cover']['url']);
|
|
|
|
$game['cover'] = IGDBController::prepCover($game['cover']['url']);
|
|
|
|
|
|
|
|
}
|
|
|
|
# Prep Genre
|
|
|
|
# Prep Genre
|
|
|
|
$genre_names = [];
|
|
|
|
if (isset($game['genres'])){
|
|
|
|
foreach ($game['genres'] as $genre){
|
|
|
|
$game['genres'] = IGDBController::prepGenre($game['genres']);
|
|
|
|
array_push($genre_names, $genre['name']);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$game['genres'] = $genre_names;
|
|
|
|
|
|
|
|
# Prep involved Companies
|
|
|
|
# Prep involved Companies
|
|
|
|
|
|
|
|
if (isset($game['involved_companies'])){
|
|
|
|
$game['involved_companies'] = IGDBController::prepInvolvedCompanies($game['involved_companies']);
|
|
|
|
$game['involved_companies'] = IGDBController::prepInvolvedCompanies($game['involved_companies']);
|
|
|
|
|
|
|
|
}
|
|
|
|
# TODO complete Preper Functions
|
|
|
|
# Prep keywords
|
|
|
|
|
|
|
|
if (isset($game['keywords'])){
|
|
|
|
|
|
|
|
$game['keywords'] = IGDBController::prepKeywords($game['keywords']);
|
|
|
|
|
|
|
|
}
|
|
|
|
# Prep platforms
|
|
|
|
# Prep platforms
|
|
|
|
|
|
|
|
if (isset($game['platforms'])){
|
|
|
|
|
|
|
|
$game['platforms'] = IGDBController::prepPlatforms($game['platforms']);
|
|
|
|
|
|
|
|
}
|
|
|
|
# Prep release dates
|
|
|
|
# Prep release dates
|
|
|
|
# Prep summary
|
|
|
|
if (isset($game['release_dates'])){
|
|
|
|
# Prep tags
|
|
|
|
$game['release_dates'] = IGDBController::prepReleaseDates($game['release_dates']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# Prep screenshots
|
|
|
|
|
|
|
|
if (isset($game['screenshots'])){
|
|
|
|
|
|
|
|
$game['screenshots'] = IGDBController::prepScreenshots($game['screenshots']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
# Prep tags // TODO Check because complex Tag-number conversion
|
|
|
|
|
|
|
|
#$game['tags'] = IGDBController::prepTags($game['tags']);
|
|
|
|
# Prep themes
|
|
|
|
# Prep themes
|
|
|
|
|
|
|
|
if (isset($game['themes'])){
|
|
|
|
|
|
|
|
$game['themes'] = IGDBController::prepThemes($game['themes']);
|
|
|
|
|
|
|
|
}
|
|
|
|
# Prep websites
|
|
|
|
# Prep websites
|
|
|
|
|
|
|
|
if (isset($game['websites'])){
|
|
|
|
|
|
|
|
$game['websites'] = IGDBController::prepWebsites($game['websites']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abort_if(!$game, 404);
|
|
|
|
abort_if(!$game, 404);
|
|
|
|
#dd($game);
|
|
|
|
#dd($game);
|
|
|
@ -75,8 +103,7 @@ class IGDBController extends Controller
|
|
|
|
return $response;
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function searchGameBySlug(string $slug)
|
|
|
|
public static function searchGameBySlug(string $slug){
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$game_list = Http::withHeaders(config('services.igdb'))->withBody(
|
|
|
|
$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;
|
|
|
|
"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;
|
|
|
@ -91,8 +118,7 @@ class IGDBController extends Controller
|
|
|
|
return $game[0];
|
|
|
|
return $game[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function getAgeRatingData()
|
|
|
|
public static function getAgeRatingData(){
|
|
|
|
{
|
|
|
|
|
|
|
|
/* *Note* Nullable (einige Felder sind nicht bei allen Einträgen gesetzt)
|
|
|
|
/* *Note* Nullable (einige Felder sind nicht bei allen Einträgen gesetzt)
|
|
|
|
field type description
|
|
|
|
field type description
|
|
|
|
category Category Enum The organization that has issued a specific rating
|
|
|
|
category Category Enum The organization that has issued a specific rating
|
|
|
@ -278,6 +304,13 @@ class IGDBController extends Controller
|
|
|
|
$prep_cover = Str::replaceFirst('thumb', 'cover_big', $cover_url);
|
|
|
|
$prep_cover = Str::replaceFirst('thumb', 'cover_big', $cover_url);
|
|
|
|
return $prep_cover;
|
|
|
|
return $prep_cover;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function prepGenre($genres){
|
|
|
|
|
|
|
|
$genre_names = [];
|
|
|
|
|
|
|
|
foreach ($genres as $genre){
|
|
|
|
|
|
|
|
array_push($genre_names, $genre['name']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $genre_names;
|
|
|
|
|
|
|
|
}
|
|
|
|
public static function prepInvolvedCompanies ($companies_data){
|
|
|
|
public static function prepInvolvedCompanies ($companies_data){
|
|
|
|
$companies_names = [];
|
|
|
|
$companies_names = [];
|
|
|
|
foreach ($companies_data as $name_data){
|
|
|
|
foreach ($companies_data as $name_data){
|
|
|
@ -285,4 +318,91 @@ class IGDBController extends Controller
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $companies_names;
|
|
|
|
return $companies_names;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function prepKeywords ($keywords){
|
|
|
|
|
|
|
|
$prep_keywords = [];
|
|
|
|
|
|
|
|
foreach ($keywords as $keyword_data){
|
|
|
|
|
|
|
|
array_push($prep_keywords, $keyword_data['name']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $prep_keywords;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function prepPlatforms ($platforms){
|
|
|
|
|
|
|
|
$prep_platforms = [];
|
|
|
|
|
|
|
|
foreach ($platforms as $platform_data){
|
|
|
|
|
|
|
|
array_push($prep_platforms, $platform_data['abbreviation']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $prep_platforms;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function prepReleaseDates ($rel_dates){
|
|
|
|
|
|
|
|
$prep_dates = [];
|
|
|
|
|
|
|
|
foreach ($rel_dates as $index => $rel_date_data){
|
|
|
|
|
|
|
|
$region = $rel_date_data['region'];
|
|
|
|
|
|
|
|
switch($region){
|
|
|
|
|
|
|
|
case 1: # Europe
|
|
|
|
|
|
|
|
$region = 'europe';
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: # north_america
|
|
|
|
|
|
|
|
$region = 'north_america';
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: # australia
|
|
|
|
|
|
|
|
$region = 'australia';
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: # new_zealand
|
|
|
|
|
|
|
|
$region = 'new_zealand';
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5: # japan
|
|
|
|
|
|
|
|
$region = 'japan';
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6: # china
|
|
|
|
|
|
|
|
$region = 'china';
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7: # asia
|
|
|
|
|
|
|
|
$region = 'asia';
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8: # worldwide
|
|
|
|
|
|
|
|
$region = 'worldwide';
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 9: # korea
|
|
|
|
|
|
|
|
$region = 'korea';
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 10: # brazil
|
|
|
|
|
|
|
|
$region = 'brazil';
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
array_push($prep_dates,['date' => $rel_date_data['date'], 'region' => $region ]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $prep_dates;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function prepScreenshots ($screenshots){
|
|
|
|
|
|
|
|
$prep_screens = [];
|
|
|
|
|
|
|
|
foreach ($screenshots as $screenshot_data){
|
|
|
|
|
|
|
|
array_push($prep_screens,
|
|
|
|
|
|
|
|
[
|
|
|
|
|
|
|
|
'height' => $screenshot_data['height'],
|
|
|
|
|
|
|
|
'width' => $screenshot_data['width'],
|
|
|
|
|
|
|
|
'url' => Str::replaceFirst('thumb', 'screenshot_big', $screenshot_data['url'])
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $prep_screens;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function prepTags($tags){
|
|
|
|
|
|
|
|
$prep_tags = [];
|
|
|
|
|
|
|
|
foreach ($tags as $tag_data){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $prep_tags;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function prepThemes($themes){
|
|
|
|
|
|
|
|
$prep_themes = [];
|
|
|
|
|
|
|
|
foreach ($themes as $theme_data){
|
|
|
|
|
|
|
|
array_push($prep_themes,$theme_data['name']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $prep_themes;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function prepWebsites($websites){
|
|
|
|
|
|
|
|
$prep_sites = [];
|
|
|
|
|
|
|
|
foreach ($websites as $website_data){
|
|
|
|
|
|
|
|
array_push($prep_sites,$website_data['url']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $prep_sites;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|