MorphMany
class MorphMany extends MorphOneOrMany (View source)
Methods
Create a new morph one or many 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.
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.
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.
Details
in MorphOneOrMany 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.
in MorphOneOrMany at line line 48
void
addConstraints()
Set the base constraints on the relation query.
in MorphOneOrMany at line line 77
void
addEagerConstraints(
array $models)
Set the constraints for an eager load of the relation.
at line line 26
array
initRelation(
array $models,
string $relation)
Initialize the relation on a set of models.
at line line 43
array
match(
array $models,
Collection $results,
string $relation)
Match the eagerly loaded results to their parents.
in MorphOneOrMany at line line 64
Builder
getRelationCountQuery(
Builder $query,
Builder $parent)
Get the relationship count query.
static
mixed
noConstraints(
Closure $callback)
Run a callback with constraints disabled on the relation.
in HasOneOrMany at line line 401
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 80
Builder
getRelationCountQueryForSelfRelation(
Builder $query,
Builder $parent)
Add the constraints for a relationship count query on the same table.
in HasOneOrMany at line line 122
array
matchOne(
array $models,
Collection $results,
string $relation)
Match the eagerly loaded results to their single parents.
in HasOneOrMany at line line 135
array
matchMany(
array $models,
Collection $results,
string $relation)
Match the eagerly loaded results to their many parents.
in MorphOneOrMany at line line 90
Model
save(
Model $model)
Attach a model instance to the parent model.
in HasOneOrMany at line line 225
Collection|array
saveMany(
Collection|array $models)
Attach a collection of models to the parent instance.
in MorphOneOrMany at line line 104
Collection|Model
findOrNew(
mixed $id,
array $columns = array('*'))
Find a related model by its primary key or return new instance of the related model.
in MorphOneOrMany at line line 124
Model
firstOrNew(
array $attributes)
Get the first related model record matching the attributes or instantiate it.
in MorphOneOrMany at line line 144
Model
firstOrCreate(
array $attributes)
Get the first related record matching the attributes or create it.
in MorphOneOrMany at line line 160
Model
updateOrCreate(
array $attributes,
array $values = array())
Create or update a related record matching the attributes, and fill it with values.
in MorphOneOrMany at line line 177
Model
create(
array $attributes)
Create a new instance of the related model.
in HasOneOrMany at line line 328
array
createMany(
array $records)
Create an array of new instances of the related model.
in HasOneOrMany at line line 345
int
update(
array $attributes)
Perform an update on all the related models.
in HasOneOrMany at line line 359
string
getHasCompareKey()
Get the key for comparing against the parent key in "has" query.
in MorphOneOrMany at line line 219
string
getPlainMorphType()
Get the plain morph type name without the table.