BelongsTo
Extends
Uses
Properties
$foreignKey string
The foreign key of the parent model.
$ownerKey string
The associated key on the parent model.
$relationName string
The name of the relationship.
Methods
__construct ( Builder $query , Model $child , $foreignKey , $ownerKey , $relationName ) : void
Create a new belongs to relationship instance.
Parameters
getResults ( ) : mixed
Get the results of the relationship.
addConstraints ( ) : void
Set the base constraints on the relation query.
addEagerConstraints ( array $models ) : void
Set the constraints for an eager load of the relation.
Parameters
- $models array
getEagerModelKeys ( array $models ) : array
Gather the keys from an array of related models.
Parameters
- $models array
initRelation ( array $models , $relation ) : array
Initialize the relation on a set of models.
Parameters
- $models array
- $relation string
match ( array $models , Collection $results , $relation ) : array
Match the eagerly loaded results to their parents.
Parameters
- $models array
- $results Collection
- $relation string
associate ( $model ) : Model
Associate the model instance to the given parent.
Parameters
- $model Model |int|string|null
getRelationExistenceQuery ( Builder $query , Builder $parentQuery , $columns ) : Builder
Add the constraints for a relationship query.
Parameters
getRelationExistenceQueryForSelfRelation ( Builder $query , Builder $parentQuery , $columns ) : Builder
Add the constraints for a relationship query on the same table.
Parameters
relationHasIncrementingId ( ) : bool
Determine if the related model has an auto-incrementing ID.
newRelatedInstanceFor ( Model $parent ) : Model
Make a new related instance for the given model.
Parameters
- $parent Model
getForeignKeyName ( ) : string
Get the foreign key of the relationship.
getQualifiedForeignKeyName ( ) : string
Get the fully qualified foreign key of the relationship.
getParentKey ( ) : mixed
Get the key value of the child's foreign key.
getOwnerKeyName ( ) : string
Get the associated key of the relationship.
getQualifiedOwnerKeyName ( ) : string
Get the fully qualified associated key of the relationship.
getRelatedKeyFrom ( Model $model ) : mixed
Get the value of the model's associated key.
Parameters
- $model Model
getRelationName ( ) : string
Get the name of the relationship.