protected $fillable = ['name', 'description', 'image_id'];
- protected $hidden = ['restricted', 'image_id', 'deleted_at'];
+ protected $hidden = ['image_id', 'deleted_at'];
/**
* Get the books in this shelf.
*/
public function coverImageTypeKey(): string
{
- return 'cover_shelf';
+ return 'cover_bookshelf';
}
/**
$maxOrder = $this->books()->max('order');
$this->books()->attach($book->id, ['order' => $maxOrder + 1]);
}
+
+ /**
+ * Get a visible shelf by its slug.
+ * @throws \Illuminate\Database\Eloquent\ModelNotFoundException
+ */
+ public static function getBySlug(string $slug): self
+ {
+ return static::visible()->where('slug', '=', $slug)->firstOrFail();
+ }
}