MorphOneOrMany
class MorphOneOrMany extends HasOneOrMany (View source)
Methods
Create a new morph one or many relationship instance.
Set the base constraints on the relation query.
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.
Add the constraints for a relationship count query.
Get the relationship query.
Set or get the morph map for polymorphic relations.
Handle dynamic method calls to the relationship.
Add the constraints for a relationship query on the same table.
Match the eagerly loaded results to their single parents.
Match the eagerly loaded results to their many parents.
Find a related model by its primary key or return new instance of the related model.
Get the first related model record matching the attributes or instantiate it.
Get the first related record matching the attributes or create it.
Create or update a related record matching the attributes, and fill it with values.
Create an array of new instances of the related model.
Get the key for comparing against the parent key in "has" query.
Get the foreign key "type" name.
Get the plain morph type name without the table.
Get the class name of the parent model.
Details
at line line 34
void
__construct(
Builder $query,
Model $parent,
string $type,
string $id,
string $localKey)
Create a new morph one or many relationship instance.
at line line 78
void
addEagerConstraints(
array $models)
Set the constraints for an eager load of the relation.
abstract
array
initRelation(
array $models,
string $relation)
Initialize the relation on a set of models.
abstract
array
match(
array $models,
Collection $results,
string $relation)
Match the eagerly loaded results to their parents.
Builder
getRelationCountQuery(
Builder $query,
Builder $parent)
Add the constraints for a relationship count query.
at line line 65
Builder
getRelationQuery(
Builder $query,
Builder $parent,
array|mixed $columns = array('*'))
Get the relationship query.
static
mixed
noConstraints(
Closure $callback)
Run a callback with constraints disabled on the relation.
in HasOneOrMany at line line 403
string
getQualifiedParentKeyName()
Get the fully qualified parent key name.
static
array
morphMap(
array $map = null,
bool $merge = true)
Set or get the morph map for polymorphic relations.
in HasOneOrMany at line line 82
Builder
getRelationQueryForSelfRelation(
Builder $query,
Builder $parent,
array|mixed $columns = array('*'))
Add the constraints for a relationship query on the same table.
in HasOneOrMany at line line 124
array
matchOne(
array $models,
Collection $results,
string $relation)
Match the eagerly loaded results to their single parents.
in HasOneOrMany at line line 137
array
matchMany(
array $models,
Collection $results,
string $relation)
Match the eagerly loaded results to their many parents.
in HasOneOrMany at line line 227
Traversable|array
saveMany(
Traversable|array $models)
Attach a collection of models to the parent instance.
at line line 105
Collection|Model
findOrNew(
mixed $id,
array $columns = array('*'))
Find a related model by its primary key or return new instance of the related model.
at line line 125
Model
firstOrNew(
array $attributes)
Get the first related model record matching the attributes or instantiate it.
at line line 145
Model
firstOrCreate(
array $attributes)
Get the first related record matching the attributes or create it.
at line line 161
Model
updateOrCreate(
array $attributes,
array $values = array())
Create or update a related record matching the attributes, and fill it with values.
in HasOneOrMany at line line 330
array
createMany(
array $records)
Create an array of new instances of the related model.
in HasOneOrMany at line line 347
int
update(
array $attributes)
Perform an update on all the related models.
in HasOneOrMany at line line 361
string
getHasCompareKey()
Get the key for comparing against the parent key in "has" query.