class Copy extends BaseModel (View source)

Represents a physical copy of a book in the system.

Each copy is linked to a specific book and can have multiple loans associated with it.

Properties

bool $incrementing

Indicates that the model does not use auto-incrementing IDs.

from  BaseModel
protected string $keyType

The data type of the primary key ID.

from  BaseModel
bool $timestamps

Indicates that the model does not use timestamps.

protected string $table

The database table used by this model.

protected array<int,string> $fillable

The attributes that are mass assignable.

Methods

string|null
getIdAttribute(mixed $value)

Converts the binary UUID stored in the database into a string UUID.

static void
boot()

Boot function for the model.

string|null
getBookIdAttribute(mixed $value)

Converts the binary UUID from the database to a string UUID.

BelongsTo
book()

Defines the relationship between a copy and its parent book.

HasMany
loans()

Defines the relationship between a copy and its loans.

Details

string|null getIdAttribute(mixed $value)

Converts the binary UUID stored in the database into a string UUID.

Parameters

mixed $value

binary value from the database

Return Value

string|null

UUID in string format, or null if not set

static protected void boot()

Boot function for the model.

This ensures that every new record automatically gets a UUID assigned if no ID is provided during creation.

Return Value

void

string|null getBookIdAttribute(mixed $value)

Converts the binary UUID from the database to a string UUID.

Parameters

mixed $value

binary UUID value

Return Value

string|null

string UUID or null if not set

BelongsTo book()

Defines the relationship between a copy and its parent book.

Return Value

BelongsTo

the book that this copy belongs to

HasMany loans()

Defines the relationship between a copy and its loans.

A copy can be loaned multiple times, each recorded as a Loan entity.

Return Value

HasMany

the collection of loans associated with this copy