*/ protected $guarded = []; /** * @var array */ protected $casts = [ 'cover' => 'boolean', 'backdrop' => 'boolean', 'genres_id' => 'integer', 'releasedate' => 'date', ]; /** * Get the genre for this game. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<\App\Models\Genre, $this> */ public function genre(): BelongsTo { return $this->belongsTo(Genre::class, 'genres_id'); } /** * Get the releases for this game. * * @return \Illuminate\Database\Eloquent\Relations\HasMany<\App\Models\Release, $this> */ public function releases(): HasMany { return $this->hasMany(Release::class, 'gamesinfo_id'); } public function searchableAs(): string { return 'ix_title_ft'; } /** * @return array */ public function toSearchableArray(): array { return [ 'title' => $this->title, ]; } /** * Get the cover image path. */ public function getCoverPath(): ?string { if (! $this->cover) { return null; } $path = config('nntmux_settings.covers_path').'/games/'.$this->id.'.jpg'; return file_exists($path) ? $path : null; } /** * Get the backdrop image path. */ public function getBackdropPath(): ?string { if (! $this->backdrop) { return null; } $path = config('nntmux_settings.covers_path').'/games/'.$this->id.'-backdrop.jpg'; return file_exists($path) ? $path : null; } }