*/ protected $guarded = []; /** * 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 { if ((int) $this->id <= 0) { return ''; } return storage_path('covers/book/'.$this->id.'.jpg'); } /** * Check if cover image exists. */ public function hasCoverImage(): bool { $coverPath = $this->getCoverPath(); return $coverPath !== '' && file_exists($coverPath); } /** * Get the cover URL. */ public function getCoverUrl(): ?string { if ((int) $this->id <= 0 || ! $this->cover || ! $this->hasCoverImage()) { return null; } return url('/covers/book/'.$this->id.'.jpg'); } }