class Book extends BaseModel (View source)

View model representing books.

Properties

bool $timestamps
protected string $table
protected array<int,string> $guarded

Methods

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.

static Collection
getFilterData(null|Builder $query = null)

Returns filterable book data (genre_name, publisher).

Details

save(array $options = [])

Prevents saving, enforcing read-only behavior for view models.

Parameters

array $options

Exceptions

Exception

string|null getIdAttribute(null|string $value)

Converts binary UUID (BLOB) to string representation.

Parameters

null|string $value

Return Value

string|null

string|null getGenreIdAttribute(null|string $value)

Converts binary UUID (BLOB) to string for genre_id.

Parameters

null|string $value

Return Value

string|null

string|null getIsbnAttribute(null|string $value)

Formats ISBN as a readable 13-digit string.

Parameters

null|string $value

Return Value

string|null

BelongsTo genre()

Book belongs to a Genre.

Return Value

BelongsTo

HasMany copies()

Book has many Copies.

Return Value

HasMany

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.

Return Value

string

A formatted string of copy numbers or a placeholder if none exist.

static Collection getFilterData(null|Builder $query = null)

Returns filterable book data (genre_name, publisher).

Parameters

null|Builder $query

Return Value

Collection