*/ protected $guarded = []; public function searchableAs(): string { return 'ix_bookinfo_author_title_ft'; } /** * @return array */ public function toSearchableArray(): array { return [ 'author' => $this->author, 'title' => $this->title, ]; } /** * Get the releases associated with this book. * * @return HasMany */ public function releases(): HasMany { return $this->hasMany(Release::class, 'bookinfo_id'); } /** * Get the cover image path. */ public function getCoverPath(): string { return storage_path('covers/book/'.$this->id.'.jpg'); } /** * Check if cover image exists. */ public function hasCoverImage(): bool { return file_exists($this->getCoverPath()); } /** * Get the cover URL. */ public function getCoverUrl(): ?string { if (! $this->cover || ! $this->hasCoverImage()) { return null; } return url('/covers/book/'.$this->id.'.jpg'); } }