MorphTo
class MorphTo extends BelongsTo (View source)
Methods
Create a new morph to relationship instance.
Set the constraints for an eager load of the relation.
Initialize the relation on a set of models.
Match the eagerly loaded results to their parents.
Get the results of the relationship.
Get the results of the relationship.
Add the constraints for a relationship count query.
Set or get the morph map for polymorphic relations.
Handle dynamic method calls to the relationship.
Add the constraints for a relationship count query on the same table.
Dissociate previously associated model from the given parent.
Get the fully qualified foreign key of the relationship.
Get the fully qualified associated key of the relationship.
Create a new model instance by type.
Get the foreign key "type" name.
Get the dictionary used by the relationship.
Fetch soft-deleted model instances with query.
Details
at line line 50
void
__construct(
Builder $query,
Model $parent,
string $foreignKey,
string $otherKey,
string $type,
string $relation)
Create a new morph to relationship instance.
at line line 77
void
addEagerConstraints(
array $models)
Set the constraints for an eager load of the relation.
at line line 105
array
match(
array $models,
Collection $results,
string $relation)
Match the eagerly loaded results to their parents.
at line line 146
Collection
getEager()
Get the results of the relationship.
Called via eager load method of Eloquent query builder.
Builder
getRelationCountQuery(
Builder $query,
Builder $parent)
Add the constraints for a relationship count query.
static
mixed
noConstraints(
Closure $callback)
Run a callback with constraints disabled on the relation.
static
array
morphMap(
array $map = null,
bool $merge = true)
Set or get the morph map for polymorphic relations.
Builder
getRelationCountQueryForSelfRelation(
Builder $query,
Builder $parent)
Add the constraints for a relationship count query on the same table.
at line line 116
Model
associate(
Model|int $model)
Associate the model instance to the given parent.