class Model implements ExtenderInterface
Methods
Add a custom attribute type cast. Should not be applied to non-extension attributes.
Add a default value for a given attribute, which can be an explicit value, a closure, or an instance of an invokable class. Unlike with some other extenders, it CANNOT be the `::class` attribute of an invokable class.
Establish a simple belongsTo relationship from this model to another model.
Establish a simple belongsToMany relationship from this model to another model.
Establish a simple hasOne relationship from this model to another model.
Establish a simple hasMany relationship from this model to another model.
Add a relationship from this model to another model.
Details
at
line 30
__construct(string $modelClass)
at
line 41
Model
cast(string $attribute, string $cast)
Add a custom attribute type cast. Should not be applied to non-extension attributes.
at
line 53
Model
default(string $attribute, mixed $value)
Add a default value for a given attribute, which can be an explicit value, a closure, or an instance of an invokable class. Unlike with some other extenders, it CANNOT be the `::class` attribute of an invokable class.
at
line 72
Model
belongsTo(string $name, string $related, string|null $foreignKey = null, string|null $ownerKey = null)
Establish a simple belongsTo relationship from this model to another model.
This represents an inverse one-to-one or inverse one-to-many relationship. For more complex relationships, use the ->relationship method.
at
line 94
Model
belongsToMany(string $name, string $related, string|null $table = null, string|null $foreignPivotKey = null, string|null $relatedPivotKey = null, string|null $parentKey = null, string|null $relatedKey = null)
Establish a simple belongsToMany relationship from this model to another model.
This represents a many-to-many relationship. For more complex relationships, use the ->relationship method.
at
line 120
Model
hasOne(string $name, string $related, string|null $foreignKey = null, string|null $localKey = null)
Establish a simple hasOne relationship from this model to another model.
This represents a one-to-one relationship. For more complex relationships, use the ->relationship method.
at
line 139
Model
hasMany(string $name, string $related, string|null $foreignKey = null, string|null $localKey = null)
Establish a simple hasMany relationship from this model to another model.
This represents a one-to-many relationship. For more complex relationships, use the ->relationship method.
at
line 161
Model
relationship(string $name, callable|string $callback)
Add a relationship from this model to another model.