class Loan extends BaseModel (View source)

Class Loan.

Represents a view model for book loans with decrypted and formatted attributes. This model maps to the database view vw_loans and includes joined/derived data from students, copies, books, genres, and related entities.

Properties

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

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
getStudentIdAttribute(string|null $value)

Get student UUID as string from binary.

string|null
getBookIdAttribute(string|null $value)

Get book UUID as string from binary.

string|null
getCopyIdAttribute(string|null $value)

Get copy UUID as string from binary.

string|null
getGenreIdAttribute(string|null $value)

Get genre UUID as string from binary.

string|null
getSchoolClassIdAttribute(string|null $value)

Get school class UUID as string from binary.

string|null
getCpfAttribute(string|null $value)

Decrypts and formats CPF number as XXX.XXX.XXX-XX.

string|null
getEmailAttribute(string|null $value)

Decrypts email address.

string|null
getPhoneAttribute(string|null $value)

Decrypts and formats phone number as (XX) XXXXX-XXXX.

string|null
getIsbnAttribute(string|null $value)

Formats ISBN-13 number as XXX-X-XXXX-XXXX-X.

BelongsTo
student()

Defines the relationship between a loan and its student.

BelongsTo
copy()

Defines the relationship between a loan and a copy.

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

Retrieves distinct values for filtering loan data.

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

Retrieves lightweight loan info for sidebar rendering.

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 getStudentIdAttribute(string|null $value)

Get student UUID as string from binary.

Parameters

string|null $value

binary UUID from the database

Return Value

string|null

UUID as string or null if value is null

string|null getBookIdAttribute(string|null $value)

Get book UUID as string from binary.

Parameters

string|null $value

binary UUID from the database

Return Value

string|null

UUID as string or null if value is null

string|null getCopyIdAttribute(string|null $value)

Get copy UUID as string from binary.

Parameters

string|null $value

binary UUID from the database

Return Value

string|null

UUID as string or null if value is null

string|null getGenreIdAttribute(string|null $value)

Get genre UUID as string from binary.

Parameters

string|null $value

binary UUID from the database

Return Value

string|null

UUID as string or null if value is null

string|null getSchoolClassIdAttribute(string|null $value)

Get school class UUID as string from binary.

Parameters

string|null $value

binary UUID from the database

Return Value

string|null

UUID as string or null if value is null

string|null getCpfAttribute(string|null $value)

Decrypts and formats CPF number as XXX.XXX.XXX-XX.

Parameters

string|null $value

encrypted CPF from the database

Return Value

string|null

formatted CPF or null if value is null

string|null getEmailAttribute(string|null $value)

Decrypts email address.

Parameters

string|null $value

encrypted email from the database

Return Value

string|null

decrypted email or null if value is null

string|null getPhoneAttribute(string|null $value)

Decrypts and formats phone number as (XX) XXXXX-XXXX.

Parameters

string|null $value

encrypted phone from the database

Return Value

string|null

formatted phone or decrypted raw value if pattern doesn't match

string|null getIsbnAttribute(string|null $value)

Formats ISBN-13 number as XXX-X-XXXX-XXXX-X.

Parameters

string|null $value

raw ISBN value

Return Value

string|null

formatted ISBN or numbers-only string if not 13 digits

BelongsTo student()

Defines the relationship between a loan and its student.

Return Value

BelongsTo

BelongsTo copy()

Defines the relationship between a loan and a copy.

Return Value

BelongsTo

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

Retrieves distinct values for filtering loan data.

Parameters

null|Builder $query

optional query builder instance

Return Value

Collection

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

Retrieves lightweight loan info for sidebar rendering.

If a custom query is provided:

  • If it returns results, use them.
  • If it returns no results, fallback to the default dataset.

Parameters

null|Builder $query

optional query builder instance

Return Value

Collection