Book
class Book extends BaseModel (View source)
Represents a book entity within the system.
Each book record stores its basic metadata (ISBN, title, author, etc.) and is associated with a genre and multiple physical copies.
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.
Converts the binary UUID from the database to a string UUID.
Defines the relationship between the book and its genre.
Defines the relationship between the book and its copies.
Details
string|null
getIdAttribute(mixed $value)
Converts the binary UUID stored in the database into a string UUID.
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.
string|null
getGenreIdAttribute(mixed $value)
Converts the binary UUID from the database to a string UUID.
BelongsTo
genre()
Defines the relationship between the book and its genre.
HasMany
copies()
Defines the relationship between the book and its copies.
Each book can have multiple copies available for loans.