Expand IGDB data: collections, game modes, themes, perspectives, videos, websites, age ratings, similar games; add backfill command
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
0eab3e8dbf
commit
2a724c0ae2
@@ -0,0 +1,95 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
|
use App\Models\Game;
|
||||||
|
use App\Services\IgdbService;
|
||||||
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
class BackfillExtendedDataCommand extends Command
|
||||||
|
{
|
||||||
|
protected $signature = 'igdb:backfill-extended
|
||||||
|
{--limit=100 : Max number of games to process}
|
||||||
|
{--offset=0 : Skip the first N games (ordered by id)}';
|
||||||
|
|
||||||
|
protected $description = 'Backfill extended IGDB data (collections, modes, themes, videos, etc.) for existing games';
|
||||||
|
|
||||||
|
public function handle(IgdbService $igdb): int
|
||||||
|
{
|
||||||
|
$limit = (int) $this->option('limit');
|
||||||
|
$offset = (int) $this->option('offset');
|
||||||
|
|
||||||
|
$games = Game::whereNotNull('igdb_id')
|
||||||
|
->orderBy('id')
|
||||||
|
->skip($offset)
|
||||||
|
->take($limit)
|
||||||
|
->get();
|
||||||
|
|
||||||
|
$total = $games->count();
|
||||||
|
|
||||||
|
if ($total === 0) {
|
||||||
|
$this->info('No games found to process.');
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info("Processing {$total} games (offset: {$offset})…");
|
||||||
|
$this->newLine();
|
||||||
|
|
||||||
|
$n = 0;
|
||||||
|
foreach ($games->chunk(10) as $batch) {
|
||||||
|
$igdbIds = $batch->pluck('igdb_id')->all();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$igdbResults = $igdb->getGamesByIds($igdbIds);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->error('IGDB request failed: ' . $e->getMessage());
|
||||||
|
return self::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$indexed = collect($igdbResults)->keyBy('id');
|
||||||
|
|
||||||
|
foreach ($batch as $game) {
|
||||||
|
$n++;
|
||||||
|
$igdbData = $indexed->get($game->igdb_id);
|
||||||
|
|
||||||
|
if (!$igdbData) {
|
||||||
|
$this->warn(" [{$n}/{$total}] No IGDB data for: {$game->title} (igdb_id={$game->igdb_id})");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$igdb->syncExtendedData($game, $igdbData);
|
||||||
|
$this->line(" [{$n}/{$total}] Processed: {$game->title}");
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->warn(" [{$n}/{$total}] Failed {$game->title}: " . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
usleep(250000); // 250ms between IGDB batches
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->newLine();
|
||||||
|
$this->info('Extended data sync complete. Resolving similar_games pivot…');
|
||||||
|
|
||||||
|
$this->resolveSimilarGames();
|
||||||
|
|
||||||
|
$this->info('Done.');
|
||||||
|
return self::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function resolveSimilarGames(): void
|
||||||
|
{
|
||||||
|
$resolved = 0;
|
||||||
|
Game::whereNotNull('similar_game_igdb_ids')->chunk(100, function ($games) use (&$resolved) {
|
||||||
|
foreach ($games as $game) {
|
||||||
|
$ids = $game->similar_game_igdb_ids;
|
||||||
|
if (empty($ids)) continue;
|
||||||
|
|
||||||
|
$similarIds = Game::whereIn('igdb_id', $ids)->pluck('id');
|
||||||
|
$game->similarGames()->sync($similarIds);
|
||||||
|
$resolved++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$this->line(" Resolved similar_games for {$resolved} games.");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -89,5 +89,7 @@ trait UpsertsGames
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$igdb->syncExtendedData($game, $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,11 @@ class GameController extends Controller
|
|||||||
|
|
||||||
public function show(Game $game)
|
public function show(Game $game)
|
||||||
{
|
{
|
||||||
$game->load(['genres', 'platforms', 'companies', 'screenshots', 'reviews.user']);
|
$game->load([
|
||||||
|
'genres', 'platforms', 'companies', 'screenshots', 'reviews.user',
|
||||||
|
'collection', 'gameModes', 'themes', 'playerPerspectives', 'videos', 'websites',
|
||||||
|
'similarGames' => fn($q) => $q->published()->with(['genres'])->limit(6),
|
||||||
|
]);
|
||||||
|
|
||||||
$userGame = null;
|
$userGame = null;
|
||||||
$userReview = null;
|
$userReview = null;
|
||||||
@@ -64,8 +68,10 @@ class GameController extends Controller
|
|||||||
->limit(20)
|
->limit(20)
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$similarGames = collect();
|
// Use IGDB similar_games if available, otherwise fall back to genre-based
|
||||||
if ($game->genres->isNotEmpty()) {
|
if ($game->similarGames->isNotEmpty()) {
|
||||||
|
$similarGames = $game->similarGames;
|
||||||
|
} elseif ($game->genres->isNotEmpty()) {
|
||||||
$similarGames = Game::published()
|
$similarGames = Game::published()
|
||||||
->whereHas('genres', fn($q) => $q->whereIn('genres.id', $game->genres->pluck('id')))
|
->whereHas('genres', fn($q) => $q->whereIn('genres.id', $game->genres->pluck('id')))
|
||||||
->where('id', '!=', $game->id)
|
->where('id', '!=', $game->id)
|
||||||
@@ -73,6 +79,8 @@ class GameController extends Controller
|
|||||||
->orderByDesc('rating_avg')
|
->orderByDesc('rating_avg')
|
||||||
->limit(6)
|
->limit(6)
|
||||||
->get();
|
->get();
|
||||||
|
} else {
|
||||||
|
$similarGames = collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = view('games.show', compact('game', 'userGame', 'userReview', 'userLists', 'comments', 'similarGames'));
|
$response = view('games.show', compact('game', 'userGame', 'userReview', 'userLists', 'comments', 'similarGames'));
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
class Collection extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['igdb_id', 'name', 'slug'];
|
||||||
|
|
||||||
|
public function games(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Game::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
+45
-2
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
@@ -15,14 +16,16 @@ class Game extends Model
|
|||||||
use HasSlug, Searchable;
|
use HasSlug, Searchable;
|
||||||
|
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'igdb_id', 'slug', 'title', 'summary', 'cover_url', 'cover_thumb_url',
|
'igdb_id', 'slug', 'title', 'summary', 'storyline', 'cover_url', 'cover_thumb_url',
|
||||||
'release_date', 'release_year', 'rating_avg', 'rating_count', 'review_count',
|
'release_date', 'release_year', 'rating_avg', 'rating_count', 'review_count',
|
||||||
'library_count', 'status',
|
'library_count', 'status', 'collection_id', 'age_rating_pegi', 'age_rating_esrb',
|
||||||
|
'aggregated_rating', 'aggregated_rating_count', 'similar_game_igdb_ids',
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $casts = [
|
protected $casts = [
|
||||||
'release_date' => 'date',
|
'release_date' => 'date',
|
||||||
'rating_avg' => 'decimal:2',
|
'rating_avg' => 'decimal:2',
|
||||||
|
'similar_game_igdb_ids' => 'array',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getSlugOptions(): SlugOptions
|
public function getSlugOptions(): SlugOptions
|
||||||
@@ -32,6 +35,11 @@ class Game extends Model
|
|||||||
|
|
||||||
public function getRouteKeyName(): string { return 'slug'; }
|
public function getRouteKeyName(): string { return 'slug'; }
|
||||||
|
|
||||||
|
public function collection(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Collection::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function genres(): BelongsToMany
|
public function genres(): BelongsToMany
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(Genre::class, 'game_genre');
|
return $this->belongsToMany(Genre::class, 'game_genre');
|
||||||
@@ -67,6 +75,41 @@ class Game extends Model
|
|||||||
return $this->hasMany(GameComment::class);
|
return $this->hasMany(GameComment::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function gameModes(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(GameMode::class, 'game_game_mode');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function themes(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Theme::class, 'game_theme');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function playerPerspectives(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(PlayerPerspective::class, 'game_player_perspective');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function videos(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(GameVideo::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function websites(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(GameWebsite::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function similarGames(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(
|
||||||
|
Game::class,
|
||||||
|
'similar_games',
|
||||||
|
'game_id',
|
||||||
|
'similar_game_id'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function toSearchableArray(): array
|
public function toSearchableArray(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
|
||||||
|
class GameMode extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['igdb_id', 'name', 'slug'];
|
||||||
|
|
||||||
|
public function games(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Game::class, 'game_game_mode');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class GameVideo extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['game_id', 'igdb_id', 'name', 'video_id'];
|
||||||
|
|
||||||
|
public function game(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Game::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getYoutubeUrlAttribute(): string
|
||||||
|
{
|
||||||
|
return "https://www.youtube.com/watch?v={$this->video_id}";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getYoutubeEmbedUrlAttribute(): string
|
||||||
|
{
|
||||||
|
return "https://www.youtube.com/embed/{$this->video_id}";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
class GameWebsite extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['game_id', 'category', 'url'];
|
||||||
|
|
||||||
|
public const CATEGORY_LABELS = [
|
||||||
|
1 => 'Official',
|
||||||
|
2 => 'Wikia',
|
||||||
|
3 => 'Wikipedia',
|
||||||
|
9 => 'YouTube',
|
||||||
|
13 => 'Steam',
|
||||||
|
16 => 'Epic Games',
|
||||||
|
17 => 'GOG',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function game(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Game::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLabelAttribute(): string
|
||||||
|
{
|
||||||
|
return self::CATEGORY_LABELS[$this->category] ?? 'Website';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
|
||||||
|
class PlayerPerspective extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['igdb_id', 'name', 'slug'];
|
||||||
|
|
||||||
|
public function games(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Game::class, 'game_player_perspective');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
|
||||||
|
class Theme extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = ['igdb_id', 'name', 'slug'];
|
||||||
|
|
||||||
|
public function games(): BelongsToMany
|
||||||
|
{
|
||||||
|
return $this->belongsToMany(Game::class, 'game_theme');
|
||||||
|
}
|
||||||
|
}
|
||||||
+189
-48
@@ -2,6 +2,14 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use App\Models\Collection;
|
||||||
|
use App\Models\Company;
|
||||||
|
use App\Models\Game;
|
||||||
|
use App\Models\GameMode;
|
||||||
|
use App\Models\GameVideo;
|
||||||
|
use App\Models\GameWebsite;
|
||||||
|
use App\Models\PlayerPerspective;
|
||||||
|
use App\Models\Theme;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
@@ -13,6 +21,10 @@ class IgdbService
|
|||||||
protected string $clientSecret;
|
protected string $clientSecret;
|
||||||
protected string $baseUrl;
|
protected string $baseUrl;
|
||||||
|
|
||||||
|
// IGDB age_rating category: 1=ESRB, 2=PEGI
|
||||||
|
private const ESRB_LABELS = [6 => 'RP', 7 => 'EC', 8 => 'E', 9 => 'E10+', 10 => 'T', 11 => 'M', 12 => 'AO'];
|
||||||
|
private const PEGI_LABELS = [1 => '3', 2 => '7', 3 => '12', 4 => '16', 5 => '18'];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->client = new Client(['timeout' => 10]);
|
$this->client = new Client(['timeout' => 10]);
|
||||||
@@ -60,6 +72,27 @@ class IgdbService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function extendedFields(): string
|
||||||
|
{
|
||||||
|
return 'id,name,slug,summary,storyline,cover.image_id,first_release_date,
|
||||||
|
genres.id,genres.name,genres.slug,
|
||||||
|
platforms.id,platforms.name,platforms.slug,platforms.abbreviation,
|
||||||
|
involved_companies.company.id,involved_companies.company.name,
|
||||||
|
involved_companies.company.slug,involved_companies.developer,
|
||||||
|
involved_companies.publisher,involved_companies.porting,
|
||||||
|
screenshots.image_id,
|
||||||
|
rating,rating_count,
|
||||||
|
aggregated_rating,aggregated_rating_count,
|
||||||
|
collection.id,collection.name,collection.slug,
|
||||||
|
game_modes.id,game_modes.name,game_modes.slug,
|
||||||
|
themes.id,themes.name,themes.slug,
|
||||||
|
player_perspectives.id,player_perspectives.name,player_perspectives.slug,
|
||||||
|
videos.id,videos.name,videos.video_id,
|
||||||
|
websites.category,websites.url,
|
||||||
|
age_ratings.category,age_ratings.rating,
|
||||||
|
similar_games';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search games by title.
|
* Search games by title.
|
||||||
*/
|
*/
|
||||||
@@ -81,34 +114,33 @@ class IgdbService
|
|||||||
public function getGame(int $igdbId): ?array
|
public function getGame(int $igdbId): ?array
|
||||||
{
|
{
|
||||||
$results = $this->query('games', "
|
$results = $this->query('games', "
|
||||||
fields id,name,slug,summary,cover.image_id,first_release_date,
|
fields {$this->extendedFields()};
|
||||||
genres.id,genres.name,genres.slug,
|
|
||||||
platforms.id,platforms.name,platforms.slug,platforms.abbreviation,
|
|
||||||
involved_companies.company.id,involved_companies.company.name,
|
|
||||||
involved_companies.company.slug,involved_companies.developer,
|
|
||||||
involved_companies.publisher,
|
|
||||||
screenshots.image_id,
|
|
||||||
rating,rating_count;
|
|
||||||
where id = {$igdbId};
|
where id = {$igdbId};
|
||||||
limit 1;
|
limit 1;
|
||||||
");
|
");
|
||||||
return $results[0] ?? null;
|
return $results[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch fresh extended data for a set of IGDB IDs (for backfill).
|
||||||
|
*/
|
||||||
|
public function getGamesByIds(array $igdbIds): array
|
||||||
|
{
|
||||||
|
$ids = implode(',', $igdbIds);
|
||||||
|
return $this->query('games', "
|
||||||
|
fields {$this->extendedFields()};
|
||||||
|
where id = ({$ids});
|
||||||
|
limit " . count($igdbIds) . ";
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get popular games (by rating and rating count).
|
* Get popular games (by rating and rating count).
|
||||||
*/
|
*/
|
||||||
public function getPopularGames(int $limit = 20, int $offset = 0): array
|
public function getPopularGames(int $limit = 20, int $offset = 0): array
|
||||||
{
|
{
|
||||||
return $this->query('games', "
|
return $this->query('games', "
|
||||||
fields id,name,slug,summary,cover.image_id,first_release_date,
|
fields {$this->extendedFields()};
|
||||||
genres.id,genres.name,genres.slug,
|
|
||||||
platforms.id,platforms.name,platforms.slug,platforms.abbreviation,
|
|
||||||
involved_companies.company.id,involved_companies.company.name,
|
|
||||||
involved_companies.company.slug,involved_companies.developer,
|
|
||||||
involved_companies.publisher,
|
|
||||||
screenshots.image_id,
|
|
||||||
rating,rating_count;
|
|
||||||
where rating != null & rating_count > 100 & cover != null;
|
where rating != null & rating_count > 100 & cover != null;
|
||||||
sort rating_count desc;
|
sort rating_count desc;
|
||||||
limit {$limit};
|
limit {$limit};
|
||||||
@@ -122,14 +154,7 @@ class IgdbService
|
|||||||
public function getPopularGamesForBackfill(int $limit = 500, int $offset = 0, int $minRatings = 5): array
|
public function getPopularGamesForBackfill(int $limit = 500, int $offset = 0, int $minRatings = 5): array
|
||||||
{
|
{
|
||||||
return $this->query('games', "
|
return $this->query('games', "
|
||||||
fields id,name,slug,summary,cover.image_id,first_release_date,
|
fields {$this->extendedFields()};
|
||||||
genres.id,genres.name,genres.slug,
|
|
||||||
platforms.id,platforms.name,platforms.slug,platforms.abbreviation,
|
|
||||||
involved_companies.company.id,involved_companies.company.name,
|
|
||||||
involved_companies.company.slug,involved_companies.developer,
|
|
||||||
involved_companies.publisher,
|
|
||||||
screenshots.image_id,
|
|
||||||
rating,rating_count;
|
|
||||||
where rating != null & rating_count > {$minRatings} & cover != null;
|
where rating != null & rating_count > {$minRatings} & cover != null;
|
||||||
sort rating_count desc;
|
sort rating_count desc;
|
||||||
limit {$limit};
|
limit {$limit};
|
||||||
@@ -146,14 +171,7 @@ class IgdbService
|
|||||||
$now = now()->timestamp;
|
$now = now()->timestamp;
|
||||||
|
|
||||||
return $this->query('games', "
|
return $this->query('games', "
|
||||||
fields id,name,slug,summary,cover.image_id,first_release_date,
|
fields {$this->extendedFields()};
|
||||||
genres.id,genres.name,genres.slug,
|
|
||||||
platforms.id,platforms.name,platforms.slug,platforms.abbreviation,
|
|
||||||
involved_companies.company.id,involved_companies.company.name,
|
|
||||||
involved_companies.company.slug,involved_companies.developer,
|
|
||||||
involved_companies.publisher,
|
|
||||||
screenshots.image_id,
|
|
||||||
rating,rating_count;
|
|
||||||
where first_release_date >= {$timestamp} & first_release_date <= {$now} & cover != null;
|
where first_release_date >= {$timestamp} & first_release_date <= {$now} & cover != null;
|
||||||
sort first_release_date desc;
|
sort first_release_date desc;
|
||||||
limit {$limit};
|
limit {$limit};
|
||||||
@@ -169,14 +187,7 @@ class IgdbService
|
|||||||
$to = mktime(23, 59, 59, 12, 31, $year);
|
$to = mktime(23, 59, 59, 12, 31, $year);
|
||||||
|
|
||||||
return $this->query('games', "
|
return $this->query('games', "
|
||||||
fields id,name,slug,summary,cover.image_id,first_release_date,
|
fields {$this->extendedFields()};
|
||||||
genres.id,genres.name,genres.slug,
|
|
||||||
platforms.id,platforms.name,platforms.slug,platforms.abbreviation,
|
|
||||||
involved_companies.company.id,involved_companies.company.name,
|
|
||||||
involved_companies.company.slug,involved_companies.developer,
|
|
||||||
involved_companies.publisher,
|
|
||||||
screenshots.image_id,
|
|
||||||
rating,rating_count;
|
|
||||||
where first_release_date >= {$from} & first_release_date <= {$to} & cover != null;
|
where first_release_date >= {$from} & first_release_date <= {$to} & cover != null;
|
||||||
sort rating_count desc;
|
sort rating_count desc;
|
||||||
limit {$limit};
|
limit {$limit};
|
||||||
@@ -190,14 +201,7 @@ class IgdbService
|
|||||||
public function getGamesByPlatform(int $platformIgdbId, int $limit = 20, int $offset = 0): array
|
public function getGamesByPlatform(int $platformIgdbId, int $limit = 20, int $offset = 0): array
|
||||||
{
|
{
|
||||||
return $this->query('games', "
|
return $this->query('games', "
|
||||||
fields id,name,slug,summary,cover.image_id,first_release_date,
|
fields {$this->extendedFields()};
|
||||||
genres.id,genres.name,genres.slug,
|
|
||||||
platforms.id,platforms.name,platforms.slug,platforms.abbreviation,
|
|
||||||
involved_companies.company.id,involved_companies.company.name,
|
|
||||||
involved_companies.company.slug,involved_companies.developer,
|
|
||||||
involved_companies.publisher,
|
|
||||||
screenshots.image_id,
|
|
||||||
rating,rating_count;
|
|
||||||
where platforms = [{$platformIgdbId}] & cover != null & rating != null;
|
where platforms = [{$platformIgdbId}] & cover != null & rating != null;
|
||||||
sort rating_count desc;
|
sort rating_count desc;
|
||||||
limit {$limit};
|
limit {$limit};
|
||||||
@@ -221,6 +225,143 @@ class IgdbService
|
|||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sync all extended IGDB data onto a Game model.
|
||||||
|
*/
|
||||||
|
public function syncExtendedData(Game $game, array $data): void
|
||||||
|
{
|
||||||
|
$updates = [];
|
||||||
|
|
||||||
|
// Collection
|
||||||
|
if (!empty($data['collection'])) {
|
||||||
|
$col = $data['collection'];
|
||||||
|
$collection = Collection::firstOrCreate(
|
||||||
|
['igdb_id' => $col['id']],
|
||||||
|
['name' => $col['name'], 'slug' => $col['slug'] ?? \Str::slug($col['name'])]
|
||||||
|
);
|
||||||
|
$updates['collection_id'] = $collection->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Storyline
|
||||||
|
if (!empty($data['storyline'])) {
|
||||||
|
$updates['storyline'] = $data['storyline'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aggregated rating (critics)
|
||||||
|
if (isset($data['aggregated_rating'])) {
|
||||||
|
$updates['aggregated_rating'] = round($data['aggregated_rating'], 2);
|
||||||
|
}
|
||||||
|
if (isset($data['aggregated_rating_count'])) {
|
||||||
|
$updates['aggregated_rating_count'] = $data['aggregated_rating_count'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Age ratings
|
||||||
|
if (!empty($data['age_ratings'])) {
|
||||||
|
foreach ($data['age_ratings'] as $ar) {
|
||||||
|
if (($ar['category'] ?? null) === 1 && isset($ar['rating'])) {
|
||||||
|
$updates['age_rating_esrb'] = self::ESRB_LABELS[$ar['rating']] ?? null;
|
||||||
|
}
|
||||||
|
if (($ar['category'] ?? null) === 2 && isset($ar['rating'])) {
|
||||||
|
$updates['age_rating_pegi'] = self::PEGI_LABELS[$ar['rating']] ?? null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Similar games — store IGDB IDs for later resolution
|
||||||
|
if (!empty($data['similar_games'])) {
|
||||||
|
$updates['similar_game_igdb_ids'] = array_values(
|
||||||
|
array_filter(array_map(fn($s) => is_array($s) ? ($s['id'] ?? null) : $s, $data['similar_games']))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($updates)) {
|
||||||
|
$game->update($updates);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Game modes
|
||||||
|
if (!empty($data['game_modes'])) {
|
||||||
|
$ids = [];
|
||||||
|
foreach ($data['game_modes'] as $gm) {
|
||||||
|
$model = GameMode::firstOrCreate(
|
||||||
|
['igdb_id' => $gm['id']],
|
||||||
|
['name' => $gm['name'], 'slug' => $gm['slug'] ?? \Str::slug($gm['name'])]
|
||||||
|
);
|
||||||
|
$ids[] = $model->id;
|
||||||
|
}
|
||||||
|
$game->gameModes()->sync($ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Themes
|
||||||
|
if (!empty($data['themes'])) {
|
||||||
|
$ids = [];
|
||||||
|
foreach ($data['themes'] as $t) {
|
||||||
|
$model = Theme::firstOrCreate(
|
||||||
|
['igdb_id' => $t['id']],
|
||||||
|
['name' => $t['name'], 'slug' => $t['slug'] ?? \Str::slug($t['name'])]
|
||||||
|
);
|
||||||
|
$ids[] = $model->id;
|
||||||
|
}
|
||||||
|
$game->themes()->sync($ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Player perspectives
|
||||||
|
if (!empty($data['player_perspectives'])) {
|
||||||
|
$ids = [];
|
||||||
|
foreach ($data['player_perspectives'] as $pp) {
|
||||||
|
$model = PlayerPerspective::firstOrCreate(
|
||||||
|
['igdb_id' => $pp['id']],
|
||||||
|
['name' => $pp['name'], 'slug' => $pp['slug'] ?? \Str::slug($pp['name'])]
|
||||||
|
);
|
||||||
|
$ids[] = $model->id;
|
||||||
|
}
|
||||||
|
$game->playerPerspectives()->sync($ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Videos
|
||||||
|
if (isset($data['videos'])) {
|
||||||
|
GameVideo::where('game_id', $game->id)->delete();
|
||||||
|
foreach ($data['videos'] as $v) {
|
||||||
|
if (empty($v['video_id'])) continue;
|
||||||
|
GameVideo::create([
|
||||||
|
'game_id' => $game->id,
|
||||||
|
'igdb_id' => $v['id'] ?? null,
|
||||||
|
'name' => $v['name'] ?? null,
|
||||||
|
'video_id' => $v['video_id'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Websites
|
||||||
|
if (isset($data['websites'])) {
|
||||||
|
GameWebsite::where('game_id', $game->id)->delete();
|
||||||
|
foreach ($data['websites'] as $w) {
|
||||||
|
if (empty($w['url'])) continue;
|
||||||
|
GameWebsite::create([
|
||||||
|
'game_id' => $game->id,
|
||||||
|
'category' => $w['category'],
|
||||||
|
'url' => $w['url'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Involved companies (update existing game_company pivot with richer data)
|
||||||
|
if (!empty($data['involved_companies'])) {
|
||||||
|
$companyPivot = [];
|
||||||
|
foreach ($data['involved_companies'] as $ic) {
|
||||||
|
if (empty($ic['company']['name'])) continue;
|
||||||
|
$company = Company::firstOrCreate(
|
||||||
|
['igdb_id' => $ic['company']['id']],
|
||||||
|
['name' => $ic['company']['name'], 'slug' => \Str::slug($ic['company']['name'])]
|
||||||
|
);
|
||||||
|
$role = $ic['developer'] ? 'developer' : ($ic['publisher'] ? 'publisher' : 'other');
|
||||||
|
$companyPivot[$company->id] = ['role' => $role];
|
||||||
|
}
|
||||||
|
if (!empty($companyPivot)) {
|
||||||
|
$game->companies()->sync($companyPivot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build a full cover image URL from an IGDB image_id.
|
* Build a full cover image URL from an IGDB image_id.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
return new class extends Migration {
|
||||||
|
public function up(): void {
|
||||||
|
Schema::create('collections', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->unsignedInteger('igdb_id')->unique();
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('slug')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public function down(): void { Schema::dropIfExists('collections'); }
|
||||||
|
};
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
return new class extends Migration {
|
||||||
|
public function up(): void {
|
||||||
|
Schema::create('game_modes', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->unsignedInteger('igdb_id')->unique();
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('slug')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public function down(): void { Schema::dropIfExists('game_modes'); }
|
||||||
|
};
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
return new class extends Migration {
|
||||||
|
public function up(): void {
|
||||||
|
Schema::create('themes', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->unsignedInteger('igdb_id')->unique();
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('slug')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public function down(): void { Schema::dropIfExists('themes'); }
|
||||||
|
};
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
return new class extends Migration {
|
||||||
|
public function up(): void {
|
||||||
|
Schema::create('player_perspectives', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->unsignedInteger('igdb_id')->unique();
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('slug')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public function down(): void { Schema::dropIfExists('player_perspectives'); }
|
||||||
|
};
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
return new class extends Migration {
|
||||||
|
public function up(): void {
|
||||||
|
Schema::table('games', function (Blueprint $table) {
|
||||||
|
$table->unsignedBigInteger('collection_id')->nullable()->after('igdb_id');
|
||||||
|
$table->string('age_rating_pegi', 10)->nullable()->after('summary');
|
||||||
|
$table->string('age_rating_esrb', 10)->nullable()->after('age_rating_pegi');
|
||||||
|
$table->decimal('aggregated_rating', 5, 2)->nullable()->after('age_rating_esrb');
|
||||||
|
$table->unsignedInteger('aggregated_rating_count')->nullable()->after('aggregated_rating');
|
||||||
|
$table->text('storyline')->nullable()->after('summary');
|
||||||
|
$table->json('similar_game_igdb_ids')->nullable()->after('storyline');
|
||||||
|
|
||||||
|
$table->foreign('collection_id')->references('id')->on('collections')->nullOnDelete();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public function down(): void {
|
||||||
|
Schema::table('games', function (Blueprint $table) {
|
||||||
|
$table->dropForeign(['collection_id']);
|
||||||
|
$table->dropColumn(['collection_id', 'age_rating_pegi', 'age_rating_esrb', 'aggregated_rating', 'aggregated_rating_count', 'storyline', 'similar_game_igdb_ids']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
return new class extends Migration {
|
||||||
|
public function up(): void {
|
||||||
|
Schema::create('game_videos', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('game_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->unsignedInteger('igdb_id')->nullable();
|
||||||
|
$table->string('name')->nullable();
|
||||||
|
$table->string('video_id');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public function down(): void { Schema::dropIfExists('game_videos'); }
|
||||||
|
};
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
return new class extends Migration {
|
||||||
|
public function up(): void {
|
||||||
|
Schema::create('game_websites', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('game_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->unsignedTinyInteger('category');
|
||||||
|
$table->string('url');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public function down(): void { Schema::dropIfExists('game_websites'); }
|
||||||
|
};
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
return new class extends Migration {
|
||||||
|
public function up(): void {
|
||||||
|
Schema::create('similar_games', function (Blueprint $table) {
|
||||||
|
$table->unsignedBigInteger('game_id');
|
||||||
|
$table->unsignedBigInteger('similar_game_id');
|
||||||
|
$table->primary(['game_id', 'similar_game_id']);
|
||||||
|
$table->foreign('game_id')->references('id')->on('games')->cascadeOnDelete();
|
||||||
|
$table->foreign('similar_game_id')->references('id')->on('games')->cascadeOnDelete();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public function down(): void { Schema::dropIfExists('similar_games'); }
|
||||||
|
};
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
return new class extends Migration {
|
||||||
|
public function up(): void {
|
||||||
|
Schema::create('game_game_mode', function (Blueprint $table) {
|
||||||
|
$table->foreignId('game_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->foreignId('game_mode_id')->constrained('game_modes')->cascadeOnDelete();
|
||||||
|
$table->primary(['game_id', 'game_mode_id']);
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('game_theme', function (Blueprint $table) {
|
||||||
|
$table->foreignId('game_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->foreignId('theme_id')->constrained('themes')->cascadeOnDelete();
|
||||||
|
$table->primary(['game_id', 'theme_id']);
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::create('game_player_perspective', function (Blueprint $table) {
|
||||||
|
$table->foreignId('game_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->foreignId('player_perspective_id')->constrained('player_perspectives')->cascadeOnDelete();
|
||||||
|
$table->primary(['game_id', 'player_perspective_id']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
public function down(): void {
|
||||||
|
Schema::dropIfExists('game_player_perspective');
|
||||||
|
Schema::dropIfExists('game_theme');
|
||||||
|
Schema::dropIfExists('game_game_mode');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -236,7 +236,7 @@
|
|||||||
|
|
||||||
{{-- Companies --}}
|
{{-- Companies --}}
|
||||||
@if($game->companies->isNotEmpty())
|
@if($game->companies->isNotEmpty())
|
||||||
<div class="text-sm text-slate-500 space-y-1">
|
<div class="text-sm text-slate-500 space-y-1 mb-4">
|
||||||
@php
|
@php
|
||||||
$developers = $game->companies->where('pivot.role', 'developer');
|
$developers = $game->companies->where('pivot.role', 'developer');
|
||||||
$publishers = $game->companies->where('pivot.role', 'publisher');
|
$publishers = $game->companies->where('pivot.role', 'publisher');
|
||||||
@@ -250,6 +250,87 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
{{-- Extended metadata --}}
|
||||||
|
<div class="text-sm text-slate-400 space-y-2">
|
||||||
|
@if($game->collection)
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<span class="text-slate-500 w-36 flex-shrink-0">Series / Collection</span>
|
||||||
|
<span class="text-slate-300">{{ $game->collection->name }}</span>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if($game->gameModes->isNotEmpty())
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<span class="text-slate-500 w-36 flex-shrink-0">Game Modes</span>
|
||||||
|
<span class="text-slate-300">{{ $game->gameModes->pluck('name')->join(', ') }}</span>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if($game->themes->isNotEmpty())
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<span class="text-slate-500 w-36 flex-shrink-0">Themes</span>
|
||||||
|
<span class="text-slate-300">{{ $game->themes->pluck('name')->join(', ') }}</span>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if($game->playerPerspectives->isNotEmpty())
|
||||||
|
<div class="flex gap-2">
|
||||||
|
<span class="text-slate-500 w-36 flex-shrink-0">Perspective</span>
|
||||||
|
<span class="text-slate-300">{{ $game->playerPerspectives->pluck('name')->join(', ') }}</span>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if($game->aggregated_rating)
|
||||||
|
<div class="flex gap-2 items-center">
|
||||||
|
<span class="text-slate-500 w-36 flex-shrink-0">Critics Score</span>
|
||||||
|
<span class="px-2 py-0.5 rounded text-xs font-bold
|
||||||
|
@if($game->aggregated_rating >= 75) bg-green-900/50 text-green-300
|
||||||
|
@elseif($game->aggregated_rating >= 50) bg-yellow-900/50 text-yellow-300
|
||||||
|
@else bg-red-900/50 text-red-300
|
||||||
|
@endif">
|
||||||
|
{{ round($game->aggregated_rating) }}/100
|
||||||
|
</span>
|
||||||
|
@if($game->aggregated_rating_count)
|
||||||
|
<span class="text-slate-600 text-xs">({{ $game->aggregated_rating_count }} {{ Str::plural('review', $game->aggregated_rating_count) }})</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if($game->age_rating_pegi || $game->age_rating_esrb)
|
||||||
|
<div class="flex gap-2 items-center">
|
||||||
|
<span class="text-slate-500 w-36 flex-shrink-0">Age Ratings</span>
|
||||||
|
<div class="flex gap-2">
|
||||||
|
@if($game->age_rating_pegi)
|
||||||
|
<span class="px-2 py-0.5 bg-[#16161d] border border-white/10 rounded text-xs font-bold text-slate-300">PEGI {{ $game->age_rating_pegi }}</span>
|
||||||
|
@endif
|
||||||
|
@if($game->age_rating_esrb)
|
||||||
|
<span class="px-2 py-0.5 bg-[#16161d] border border-white/10 rounded text-xs font-bold text-slate-300">ESRB {{ $game->age_rating_esrb }}</span>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Websites --}}
|
||||||
|
@php
|
||||||
|
$importantCategories = [1, 13, 17, 16];
|
||||||
|
$featuredSites = $game->websites->whereIn('category', $importantCategories)->sortBy(fn($w) => array_search($w->category, $importantCategories));
|
||||||
|
@endphp
|
||||||
|
@if($featuredSites->isNotEmpty())
|
||||||
|
<div class="flex flex-wrap gap-2 mt-4">
|
||||||
|
@foreach($featuredSites as $site)
|
||||||
|
<a href="{{ $site->url }}" target="_blank" rel="noopener noreferrer"
|
||||||
|
class="inline-flex items-center gap-1.5 px-3 py-1.5 bg-[#16161d] border border-white/10 hover:border-purple-500/50 rounded-lg text-xs text-slate-300 hover:text-white transition-all">
|
||||||
|
@if($site->category === 13)
|
||||||
|
<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="currentColor"><path d="M11.979 0C5.678 0 .511 4.86.022 11.037l6.432 2.658c.545-.371 1.203-.59 1.912-.59.063 0 .125.004.187.006l2.861-4.142V8.91c0-2.495 2.028-4.524 4.524-4.524 2.494 0 4.524 2.029 4.524 4.524s-2.03 4.525-4.524 4.525h-.105l-4.076 2.911c0 .052.004.105.004.159 0 1.875-1.515 3.396-3.39 3.396-1.635 0-3.016-1.173-3.331-2.727L.436 15.27C1.862 20.307 6.486 24 11.979 24c6.627 0 11.999-5.373 11.999-12S18.606 0 11.979 0zM7.54 18.21l-1.473-.61c.262.543.714.999 1.314 1.25 1.297.539 2.793-.076 3.332-1.375.263-.63.264-1.319.005-1.949s-.75-1.121-1.377-1.383c-.624-.26-1.29-.249-1.878-.03l1.523.63c.956.4 1.409 1.5 1.009 2.455-.397.957-1.497 1.41-2.455 1.012H7.54zm11.415-9.303c0-1.662-1.353-3.015-3.015-3.015-1.665 0-3.015 1.353-3.015 3.015 0 1.665 1.35 3.015 3.015 3.015 1.663 0 3.015-1.35 3.015-3.015zm-5.273-.005c0-1.252 1.013-2.266 2.265-2.266 1.249 0 2.266 1.014 2.266 2.266 0 1.251-1.017 2.265-2.266 2.265-1.252 0-2.265-1.014-2.265-2.265z"/></svg>
|
||||||
|
@elseif($site->category === 17)
|
||||||
|
<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.37 0 0 5.37 0 12s5.37 12 12 12 12-5.37 12-12S18.63 0 12 0zm5.61 17.26c-.2.2-.52.2-.72 0l-4.89-4.89-4.89 4.89c-.2.2-.52.2-.72 0-.2-.2-.2-.52 0-.72l4.89-4.89-4.89-4.89c-.2-.2-.2-.52 0-.72.2-.2.52-.2.72 0l4.89 4.89 4.89-4.89c.2-.2.52-.2.72 0 .2.2.2.52 0 .72l-4.89 4.89 4.89 4.89c.2.2.2.52 0 .72z"/></svg>
|
||||||
|
@elseif($site->category === 16)
|
||||||
|
<svg class="w-3.5 h-3.5" viewBox="0 0 24 24" fill="currentColor"><path d="M0 0h24v24H0z" fill="none"/><path d="M21 6.5C21 4.6 19.5 3 17.5 3c-1.9 0-3.5 1.6-3.5 3.5C14 8.4 15.6 10 17.5 10c1.9 0 3.5-1.5 3.5-3.5zM6.5 3C4.6 3 3 4.6 3 6.5S4.6 10 6.5 10 10 8.4 10 6.5 8.4 3 6.5 3zM17.5 14c-1.9 0-3.5 1.6-3.5 3.5S15.6 21 17.5 21c1.9 0 3.5-1.5 3.5-3.5S19.4 14 17.5 14zm-11 0C4.6 14 3 15.6 3 17.5S4.6 21 6.5 21 10 19.4 10 17.5 8.4 14 6.5 14z"/></svg>
|
||||||
|
@else
|
||||||
|
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"/></svg>
|
||||||
|
@endif
|
||||||
|
{{ $site->label }}
|
||||||
|
</a>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -261,6 +342,52 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
{{-- Storyline (only if different from summary) --}}
|
||||||
|
@if($game->storyline && $game->storyline !== $game->summary)
|
||||||
|
<div class="mt-8">
|
||||||
|
<h2 class="text-lg font-semibold text-white mb-3">Storyline</h2>
|
||||||
|
<p class="text-slate-400 leading-relaxed max-w-3xl">{{ $game->storyline }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
{{-- Trailers --}}
|
||||||
|
@if($game->videos->isNotEmpty())
|
||||||
|
<div class="mt-10 pt-8 border-t border-white/5"
|
||||||
|
x-data="{
|
||||||
|
activeVideo: '{{ $game->videos->first()->video_id }}',
|
||||||
|
activeName: {{ json_encode($game->videos->first()->name ?? 'Trailer') }},
|
||||||
|
}">
|
||||||
|
<h2 class="text-lg font-semibold text-white mb-4">Videos</h2>
|
||||||
|
<div class="flex flex-col lg:flex-row gap-4">
|
||||||
|
<div class="flex-1 min-w-0">
|
||||||
|
<div class="aspect-video rounded-xl overflow-hidden bg-black">
|
||||||
|
<iframe
|
||||||
|
:src="'https://www.youtube.com/embed/' + activeVideo + '?rel=0'"
|
||||||
|
class="w-full h-full"
|
||||||
|
loading="lazy"
|
||||||
|
allowfullscreen
|
||||||
|
title="Game video"
|
||||||
|
></iframe>
|
||||||
|
</div>
|
||||||
|
<p class="text-sm text-slate-500 mt-2" x-text="activeName"></p>
|
||||||
|
</div>
|
||||||
|
@if($game->videos->count() > 1)
|
||||||
|
<div class="flex lg:flex-col gap-2 overflow-x-auto lg:overflow-y-auto lg:max-h-72 lg:w-48 flex-shrink-0">
|
||||||
|
@foreach($game->videos as $video)
|
||||||
|
<button @click="activeVideo = '{{ $video->video_id }}'; activeName = {{ json_encode($video->name ?? 'Video') }}"
|
||||||
|
class="flex-shrink-0 lg:flex-shrink rounded-lg overflow-hidden border-2 transition-all w-32 lg:w-full aspect-video bg-black"
|
||||||
|
:class="activeVideo === '{{ $video->video_id }}' ? 'border-purple-500' : 'border-transparent hover:border-white/20'">
|
||||||
|
<img src="https://img.youtube.com/vi/{{ $video->video_id }}/mqdefault.jpg"
|
||||||
|
alt="{{ $video->name ?? 'Video' }}"
|
||||||
|
class="w-full h-full object-cover">
|
||||||
|
</button>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
{{-- Screenshots --}}
|
{{-- Screenshots --}}
|
||||||
@if($game->screenshots->isNotEmpty())
|
@if($game->screenshots->isNotEmpty())
|
||||||
<div class="mt-10 pt-8 border-t border-white/5"
|
<div class="mt-10 pt-8 border-t border-white/5"
|
||||||
@@ -554,7 +681,13 @@
|
|||||||
|
|
||||||
@if($similarGames->isNotEmpty())
|
@if($similarGames->isNotEmpty())
|
||||||
<div class="mt-10 pt-8 border-t border-white/5">
|
<div class="mt-10 pt-8 border-t border-white/5">
|
||||||
<h2 class="text-lg font-semibold text-white mb-4">You Might Also Like</h2>
|
<h2 class="text-lg font-semibold text-white mb-4">
|
||||||
|
@if($game->similarGames->isNotEmpty())
|
||||||
|
Similar Games
|
||||||
|
@else
|
||||||
|
You Might Also Like
|
||||||
|
@endif
|
||||||
|
</h2>
|
||||||
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-4">
|
<div class="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-4">
|
||||||
@foreach($similarGames as $similar)
|
@foreach($similarGames as $similar)
|
||||||
<x-game-card :game="$similar" />
|
<x-game-card :game="$similar" />
|
||||||
|
|||||||
Reference in New Issue
Block a user