Book
class Book extends BaseModel (View source)
View model representing books.
Properties
| bool | $timestamps | ||
| protected string | $table | ||
| protected array<int,string> | $guarded |
Methods
Prevents saving, enforcing read-only behavior for view models.
Converts binary UUID (BLOB) to string representation.
Converts binary UUID (BLOB) to string for genre_id.
Formats ISBN as a readable 13-digit string.
Book belongs to a Genre.
Book has many Copies.
Generates a formatted string representing the sequence of copy numbers.
Returns filterable book data (genre_name, publisher).
Details
save(array $options = [])
Prevents saving, enforcing read-only behavior for view models.
string|null
getIdAttribute(null|string $value)
Converts binary UUID (BLOB) to string representation.
string|null
getGenreIdAttribute(null|string $value)
Converts binary UUID (BLOB) to string for genre_id.
string|null
getIsbnAttribute(null|string $value)
Formats ISBN as a readable 13-digit string.
BelongsTo
genre()
Book belongs to a Genre.
HasMany
copies()
Book has many Copies.
string
placeholderCopies()
Generates a formatted string representing the sequence of copy numbers.
This function collects all non-null copy numbers, sorts them, and condenses consecutive numbers into ranges. For example, if the copies are [1, 2, 3, 5, 6], the returned string will be "Ex: 1-3, 5-6". If there are no copies, it returns a placeholder indicating the absence of copies.
static Collection
getFilterData(null|Builder $query = null)
Returns filterable book data (genre_name, publisher).