MorphTo
Extends
Uses
Properties
$morphType string
The type of the polymorphic relation.
$dictionary array
All of the models keyed by ID.
$macroBuffer array
A buffer of dynamic calls to query macros.
$morphableEagerLoads array
A map of relations to load for each individual morph type.
$morphableEagerLoadCounts array
A map of relationship counts to load for each individual morph type.
$morphableConstraints array
A map of constraints to apply for each individual morph type.
Methods
__construct ( Builder $query , Model $parent , $foreignKey , $ownerKey , $type , $relation ) : void
Create a new morph to relationship instance.
Parameters
addEagerConstraints ( array $models ) : void
Set the constraints for an eager load of the relation.
Parameters
- $models array
buildDictionary ( Collection $models ) : void
Build a dictionary with the models.
Parameters
- $models Collection
getEager ( ) : mixed
Get the results of the relationship.
getResultsByType ( $type ) : Collection
Get all of the relation results for a type.
Parameters
- $type string
gatherKeysByType ( $type , $keyType ) : array
Gather all of the foreign keys for a given type.
Parameters
- $type string
- $keyType string
createModelByType ( $type ) : Model
Create a new model instance by type.
Parameters
- $type string
match ( array $models , Collection $results , $relation ) : array
Match the eagerly loaded results to their parents.
Parameters
- $models array
- $results Collection
- $relation string
matchToMorphParents ( $type , Collection $results ) : void
Match the results for a given type to their parents.
Parameters
- $type string
- $results Collection
associate ( $model ) : Model
Associate the model instance to the given parent.
Parameters
- $model Model
touch ( ) : void
Touch all of the related models for the relationship.
newRelatedInstanceFor ( Model $parent ) : Model
Make a new related instance for the given model.
Parameters
- $parent Model
getMorphType ( ) : string
Get the foreign key "type" name.
getDictionary ( ) : array
Get the dictionary used by the relationship.
morphWith ( array $with ) : MorphTo
Specify which relations to load for a given morph type.
Parameters
- $with array
morphWithCount ( array $withCount ) : MorphTo
Specify which relationship counts to load for a given morph type.
Parameters
- $withCount array
constrain ( array $callbacks ) : MorphTo
Specify constraints on the query for a given morph type.
Parameters
- $callbacks array
replayMacros ( Builder $query ) : Builder
Replay stored macro calls on the actual related instance.
Parameters
- $query Builder
__call ( $method , $parameters ) : mixed
Handle dynamic method calls to the relationship.
Parameters
- $method string
- $parameters array