HasRelationships
trait HasRelationships
Properties
$relation | The loaded relationships for the model. |
||
static protected array | $relationTypes |
Methods
No description
Returns relationship details from a supplied name.
Returns relationship details for all relations defined on this model.
Returns a relationship type based on a supplied name.
Get a relationship.
Sets a relation value directly from its attribute.
Returns a relation class object
Determines whether the specified relation should be saved when push() is called instead of save() on the model. Default: true.
Returns default relation arguments for a given type.
No description
Validate relation supplied arguments.
Define a one-to-one relationship.
Define a has-one-through relationship.
Define a one-to-many relationship.
Define a has-many-through relationship.
No description
No description
Define a polymorphic one-to-one relationship.
Define a polymorphic, inverse one-to-one or many relationship.
Define a polymorphic, inverse one-to-one or many relationship.
Define a polymorphic one-to-many relationship.
Define a polymorphic many-to-many relationship.
Define a polymorphic, inverse many-to-many relationship.
Details
at line 58
hasRelation($name)
No description
at line 70
array
getRelationDefinition(string $name)
Returns relationship details from a supplied name.
at line 81
array
getRelationDefinitions()
Returns relationship details for all relations defined on this model.
at line 108
string
getRelationType(string $name)
Returns a relationship type based on a supplied name.
at line 124
mixed
getRelationValue(string $key)
Get a relationship.
at line 141
protected $this
setRelationValue($relationName, $value)
Sets a relation value directly from its attribute.
at line 155
string
makeRelation(string $name)
Returns a relation class object
at line 177
bool
isRelationPushable(string $name)
Determines whether the specified relation should be saved when push() is called instead of save() on the model. Default: true.
at line 194
protected array
getRelationDefaults(string $type)
Returns default relation arguments for a given type.
at line 206
handleRelation($relationName)
No description
at line 334
protected array
validateRelationArgs($relationName, $optional, array $required = [])
Validate relation supplied arguments.
at line 374
HasOne
hasOne(string $related, string|null $foreignKey = null, string|null $localKey = null, null $relationName = null)
Define a one-to-one relationship.
at line 398
HasOneThrough
hasOneThrough($related, $through, $primaryKey = null, $throughKey = null, $localKey = null, $secondLocalKey = null, $relationName = null)
Define a has-one-through relationship.
This code is a duplicate of Eloquent but uses a Rain relation class.
at line 428
HasMany
hasMany(string $related, string|null $foreignKey = null, string|null $localKey = null, null $relationName = null)
Define a one-to-many relationship.
at line 459
HasManyThrough
hasManyThrough(string $related, string $through, string|null $firstKey = null, string|null $secondKey = null, string|null $localKey = null, string|null $secondLocalKey = null, null $relationName = null)
Define a has-many-through relationship.
at line 487
belongsTo($related, $foreignKey = null, $ownerKey = null, $relationName = null)
No description
at line 508
belongsToMany($related, $table = null, $foreignPivotKey = null, $relatedPivotKey = null, $parentKey = null, $relatedKey = null, $relationName = null)
No description
at line 541
MorphOne
morphOne(string $related, string $name, string|null $type = null, string|null $id = null, string|null $localKey = null, null $relationName = null)
Define a polymorphic one-to-one relationship.
at line 572
protected MorphTo
morphEagerTo(string $name, string $type, string $id, $ownerKey)
Define a polymorphic, inverse one-to-one or many relationship.
at line 594
protected MorphTo
morphInstanceTo(string $target, string $name, string $type, string $id, $ownerKey)
Define a polymorphic, inverse one-to-one or many relationship.
at line 621
MorphMany
morphMany(string $related, string $name, string|null $type = null, string|null $id = null, string|null $localKey = null, null $relationName = null)
Define a polymorphic one-to-many relationship.
at line 657
MorphToMany
morphToMany(string $related, string $name, string|null $table = null, string|null $foreignPivotKey = null, string|null $relatedPivotKey = null, string|null $parentKey = null, string|null $relatedKey = null, bool $inverse = false, null $relationName = null)
Define a polymorphic many-to-many relationship.
at line 705
MorphToMany
morphedByMany(string $related, string $name, string|null $table = null, string|null $foreignPivotKey = null, string|null $relatedPivotKey = null, string|null $parentKey = null, string|null $relatedKey = null, null $relationName = null)
Define a polymorphic, inverse many-to-many relationship.