Loan
class Loan extends BaseModel (View source)
Represents a loan (borrowed copy) in the system.
Each loan is associated with a student and a specific copy of a book. Automatically generates a unique barcode code and sets the start date on creation.
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
Converts the binary UUID stored in the database into a string UUID.
Boot method to handle model events.
Converts the stored binary student ID to UUID string.
Converts the stored binary copy ID to UUID string.
Generates a unique barcode code for the loan.
Defines the relationship to the student who borrowed the copy.
Defines the relationship to the borrowed copy.
Details
string|null
getIdAttribute(mixed $value)
Converts the binary UUID stored in the database into a string UUID.
static protected void
boot()
Boot method to handle model events.
Automatically sets the barcode and start date when creating a new loan.
string|null
getStudentIdAttribute(mixed $value)
Converts the stored binary student ID to UUID string.
string|null
getCopyIdAttribute(mixed $value)
Converts the stored binary copy ID to UUID string.
static string
generateBarCode(string $prefix = 'LN', int $length = 8)
Generates a unique barcode code for the loan.
BelongsTo
student()
Defines the relationship to the student who borrowed the copy.
BelongsTo
copy()
Defines the relationship to the borrowed copy.