*/ use HasFactory; protected static ?string $factory = GameFactory::class; protected $fillable = [ 'console_id', 'title', 'slug', 'igdb_id', 'tgdb_id', 'description', 'release_year', 'developer', 'publisher', 'genre', 'rating', 'cover_path', 'thumbnail_path', ]; protected $casts = [ 'rating' => 'decimal:1', ]; protected static function booted(): void { static::creating(function (Game $game) { if (empty($game->slug)) { $game->slug = Str::slug($game->title); } }); } public function console(): BelongsTo { return $this->belongsTo(Console::class); } public function romFiles(): HasMany { return $this->hasMany(RomFile::class); } public function saveFiles(): HasMany { return $this->hasMany(SaveFile::class); } public function getRouteKeyName(): string { return 'slug'; } }