Relation
Uses
Properties
$constraints bool
Indicates if the relation is adding constraints.
$morphMap array
An array to map class names to their morph names in the database.
$requireMorphMap bool
Prevents morph relationships without a morph map.
$selfJoinCount int
The count of self joins.
Methods
__construct ( Builder $query , Model $parent ) : void
Create a new relation instance.
Parameters
noConstraints ( Closure $callback ) : mixed
Run a callback with constraints disabled on the relation.
Parameters
- $callback Closure
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
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
getResults ( ) : mixed
Get the results of the relationship.
sole ( $columns ) : Model
Execute the query and get the first result if it's the sole matching record.
Parameters
- $columns array|string
get ( $columns ) : Collection
Execute the query as a "select" statement.
Parameters
- $columns array
touch ( ) : void
Touch all of the related models for the relationship.
rawUpdate ( array $attributes ) : int
Run a raw update against the base query.
Parameters
- $attributes array
getRelationExistenceCountQuery ( Builder $query , Builder $parentQuery ) : Builder
Add the constraints for a relationship count query.
Parameters
getRelationExistenceQuery ( Builder $query , Builder $parentQuery , $columns ) : Builder
Add the constraints for an internal relationship existence query.
Parameters
getRelationCountHash ( $incrementJoinCount ) : string
Get a relationship join table hash.
Parameters
- $incrementJoinCount bool
getKeys ( array $models , $key ) : array
Get all of the primary keys for an array of models.
Parameters
- $models array
- $key string|null
getRelationQuery ( ) : Builder
Get the query builder that will contain the relationship constraints.
getQualifiedParentKeyName ( ) : string
Get the fully qualified parent key name.
createdAt ( ) : string
Get the name of the "created at" column.
updatedAt ( ) : string
Get the name of the "updated at" column.
relatedUpdatedAt ( ) : string
Get the name of the related model's "updated at" column.
whereInMethod ( Model $model , $key ) : string
Get the name of the "where in" method for eager loading.
Parameters
- $model Model
- $key string
requireMorphMap ( $requireMorphMap ) : void
Prevent polymorphic relationships from being used without model mappings.
Parameters
- $requireMorphMap bool
requiresMorphMap ( ) : bool
Determine if polymorphic relationships require explicit model mapping.
enforceMorphMap ( array $map , $merge ) : array
Define the morph map for polymorphic relations and require all morphed models to be explicitly mapped.
Parameters
- $map array
- $merge bool
morphMap ( array $map , $merge ) : array
Set or get the morph map for polymorphic relations.
Parameters
- $map array|null
- $merge bool
buildMorphMapFromModels ( array $models ) : array|null
Builds a table-keyed array from model class names.
Parameters
- $models string[]|null
getMorphedModel ( $alias ) : string|null
Get the model associated with a custom polymorphic type.
Parameters
- $alias string
__call ( $method , $parameters ) : mixed
Handle dynamic method calls to the relationship.
Parameters
- $method string
- $parameters array
__clone ( ) : void
Force a clone of the underlying query builder when cloning.