|
|
@ -13,7 +13,7 @@ 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, 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.*, 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;
|
|
|
|
where slug=\"{$slug}\";",
|
|
|
|
where slug=\"{$slug}\";",
|
|
|
|
"text/plain"
|
|
|
|
"text/plain"
|
|
|
|
)->post('https://api.igdb.com/v4/games')
|
|
|
|
)->post('https://api.igdb.com/v4/games')
|
|
|
@ -28,20 +28,33 @@ class IGDBController extends Controller
|
|
|
|
public static function getPreparedGameDetails(string $slug)
|
|
|
|
public static function getPreparedGameDetails(string $slug)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$game = IGDBController::getGameDetails($slug);
|
|
|
|
$game = IGDBController::getGameDetails($slug);
|
|
|
|
$rating_urls = [];
|
|
|
|
|
|
|
|
# Prep Age Rating Icons
|
|
|
|
|
|
|
|
foreach ($game['age_ratings'] as $rating){
|
|
|
|
|
|
|
|
$cur_url = IGDBController::getAgeRatingIcon($rating['rating']);
|
|
|
|
|
|
|
|
array_push($rating_urls, $cur_url);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$game['age_ratings'] = $rating_ids;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Prep Age Rating Icons
|
|
|
|
|
|
|
|
$game['age_ratings'] = IGDBController::prepAgeRatings($game['age_ratings']);
|
|
|
|
|
|
|
|
# Prep alternative names
|
|
|
|
|
|
|
|
$game['alternative_names'] = IGDBController::prepAltName($game['alternative_names']);
|
|
|
|
|
|
|
|
# Prep category
|
|
|
|
|
|
|
|
$game['category'] = IGDBController::prepCategory($game['category']);
|
|
|
|
|
|
|
|
# Prep collection
|
|
|
|
|
|
|
|
$game['collection'] = IGDBController::prepCollection($game['collection']);
|
|
|
|
|
|
|
|
# Prep cover_url
|
|
|
|
|
|
|
|
$game['cover'] = IGDBController::prepCover($game['cover']['url']);
|
|
|
|
# Prep Genre
|
|
|
|
# Prep Genre
|
|
|
|
$genre_names = [];
|
|
|
|
$genre_names = [];
|
|
|
|
foreach ($game['genres'] as $genre){
|
|
|
|
foreach ($game['genres'] as $genre){
|
|
|
|
array_push($genre_names, $genre['name']);
|
|
|
|
array_push($genre_names, $genre['name']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$game['genres'] = $genre_names;
|
|
|
|
$game['genres'] = $genre_names;
|
|
|
|
|
|
|
|
# Prep involved Companies
|
|
|
|
|
|
|
|
$game['involved_companies'] = IGDBController::prepInvolvedCompanies($game['involved_companies']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO complete Preper Functions
|
|
|
|
|
|
|
|
# Prep platforms
|
|
|
|
|
|
|
|
# Prep release dates
|
|
|
|
|
|
|
|
# Prep summary
|
|
|
|
|
|
|
|
# Prep tags
|
|
|
|
|
|
|
|
# Prep themes
|
|
|
|
|
|
|
|
# Prep websites
|
|
|
|
|
|
|
|
|
|
|
|
abort_if(!$game, 404);
|
|
|
|
abort_if(!$game, 404);
|
|
|
|
#dd($game);
|
|
|
|
#dd($game);
|
|
|
@ -186,4 +199,90 @@ class IGDBController extends Controller
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $icon_url;
|
|
|
|
return $icon_url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Prep Functions
|
|
|
|
|
|
|
|
public static function prepAgeRatings ($ratings){
|
|
|
|
|
|
|
|
$rating_urls = [];
|
|
|
|
|
|
|
|
foreach ($ratings as $rating){
|
|
|
|
|
|
|
|
$cur_url = IGDBController::getAgeRatingIcon($rating['rating']);
|
|
|
|
|
|
|
|
array_push($rating_urls, $cur_url);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $rating_urls;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function prepAltName ($altNames){
|
|
|
|
|
|
|
|
$prep_alt_names = [];
|
|
|
|
|
|
|
|
foreach ($altNames as $name_data){
|
|
|
|
|
|
|
|
array_push($prep_alt_names, $name_data['name']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $prep_alt_names;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function prepCategory ($category){
|
|
|
|
|
|
|
|
$formatedCategory = $category;
|
|
|
|
|
|
|
|
switch ($formatedCategory) {
|
|
|
|
|
|
|
|
case 0 :
|
|
|
|
|
|
|
|
$formatedCategory = "main_game";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1 :
|
|
|
|
|
|
|
|
$formatedCategory = "dlc_addon";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2 :
|
|
|
|
|
|
|
|
$formatedCategory = "expansion";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3 :
|
|
|
|
|
|
|
|
$formatedCategory = "bundle";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4 :
|
|
|
|
|
|
|
|
$formatedCategory = "standalone_expansion";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5 :
|
|
|
|
|
|
|
|
$formatedCategory = "mod";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6 :
|
|
|
|
|
|
|
|
$formatedCategory = "episode";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7 :
|
|
|
|
|
|
|
|
$formatedCategory = "season";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8 :
|
|
|
|
|
|
|
|
$formatedCategory = "remake";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 9 :
|
|
|
|
|
|
|
|
$formatedCategory = "remaster";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 10 :
|
|
|
|
|
|
|
|
$formatedCategory = "expanded_game";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 11 :
|
|
|
|
|
|
|
|
$formatedCategory = "port";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 12 :
|
|
|
|
|
|
|
|
$formatedCategory = "fork";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 13 :
|
|
|
|
|
|
|
|
$formatedCategory = "pack";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 14 :
|
|
|
|
|
|
|
|
$formatedCategory = "update";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default :
|
|
|
|
|
|
|
|
$formatedCategory = "undefined";
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $formatedCategory;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function prepCollection($collection_data){
|
|
|
|
|
|
|
|
$collection_name = ['name' => $collection_data['name'], 'slug' => $collection_data['slug']];
|
|
|
|
|
|
|
|
return $collection_name;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function prepCover($cover_url){
|
|
|
|
|
|
|
|
$prep_cover = Str::replaceFirst('thumb', 'cover_big', $cover_url);
|
|
|
|
|
|
|
|
return $prep_cover;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function prepInvolvedCompanies ($companies_data){
|
|
|
|
|
|
|
|
$companies_names = [];
|
|
|
|
|
|
|
|
foreach ($companies_data as $name_data){
|
|
|
|
|
|
|
|
array_push($companies_names, $name_data['company']['name']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $companies_names;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|