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
+47
-4
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
@@ -15,14 +16,16 @@ class Game extends Model
|
||||
use HasSlug, Searchable;
|
||||
|
||||
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',
|
||||
'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 = [
|
||||
'release_date' => 'date',
|
||||
'rating_avg' => 'decimal:2',
|
||||
'release_date' => 'date',
|
||||
'rating_avg' => 'decimal:2',
|
||||
'similar_game_igdb_ids' => 'array',
|
||||
];
|
||||
|
||||
public function getSlugOptions(): SlugOptions
|
||||
@@ -32,6 +35,11 @@ class Game extends Model
|
||||
|
||||
public function getRouteKeyName(): string { return 'slug'; }
|
||||
|
||||
public function collection(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Collection::class);
|
||||
}
|
||||
|
||||
public function genres(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Genre::class, 'game_genre');
|
||||
@@ -67,6 +75,41 @@ class Game extends Model
|
||||
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
|
||||
{
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user