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 28
__construct(string $modelClass)
at
line 40
Model
dateAttribute(string $attribute)
deprecated
deprecated
Add an attribute to be treated as a date.
at
line 54
Model
cast(string $attribute, string $cast)
Add a custom attribute type cast. Should not be applied to non-extension attributes.
at
line 70
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 90
Model
belongsTo(string $name, string $related, string $foreignKey = null, string $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 113
Model
belongsToMany(string $name, string $related, string $table = null, string $foreignPivotKey = null, string $relatedPivotKey = null, string $parentKey = null, string $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 140
Model
hasOne(string $name, string $related, string $foreignKey = null, string $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 160
Model
hasMany(string $name, string $related, string $foreignKey = null, string $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.