Loan
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 | ||
| $hidden |
Methods
Prevents saving, enforcing read-only behavior for view models.
Converts binary UUID (BLOB) to string representation.
Get student UUID as string from binary.
Get book UUID as string from binary.
Get copy UUID as string from binary.
Get genre UUID as string from binary.
Get school class UUID as string from binary.
Decrypts and formats CPF number as XXX.XXX.XXX-XX.
Decrypts email address.
Decrypts and formats phone number as (XX) XXXXX-XXXX.
Formats ISBN-13 number as XXX-X-XXXX-XXXX-X.
Defines the relationship between a loan and its student.
Defines the relationship between a loan and a copy.
Retrieves distinct values for filtering loan data.
Retrieves lightweight loan info for sidebar rendering.
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
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.
If a custom query is provided:
- If it returns results, use them.
- If it returns no results, fallback to the default dataset.