HasOneOrMany
class HasOneOrMany extends Relation (View source)
Methods
Create a new has 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.
Add the constraints for a relationship query.
Get the fully qualified parent key name.
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.
Get a relationship join table hash.
Match the eagerly loaded results to their single parents.
Match the eagerly loaded results to their many parents.
Find a 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.
Perform an update on all the related models.
Get the key for comparing against the parent key in "has" query.
Get the foreign key for the relationship.
Get the plain foreign key.
Get the key value of the parent's local key.
Details
at line line 35
void
__construct(
Builder $query,
Model $parent,
string $foreignKey,
string $localKey)
Create a new has one or many relationship instance.
at line line 111
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('*'))
Add the constraints for a relationship 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.
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.
at line line 124
array
matchOne(
array $models,
Collection $results,
string $relation)
Match the eagerly loaded results to their single parents.
at line line 137
array
matchMany(
array $models,
Collection $results,
string $relation)
Match the eagerly loaded results to their many parents.
at line line 227
Traversable|array
saveMany(
Traversable|array $models)
Attach a collection of models to the parent instance.
at line line 243
Collection|Model
findOrNew(
mixed $id,
array $columns = array('*'))
Find a model by its primary key or return new instance of the related model.
at line line 260
Model
firstOrNew(
array $attributes)
Get the first related model record matching the attributes or instantiate it.
at line line 277
Model
firstOrCreate(
array $attributes)
Get the first related record matching the attributes or create it.
at line line 293
Model
updateOrCreate(
array $attributes,
array $values = array())
Create or update a related record matching the attributes, and fill it with values.
at line line 330
array
createMany(
array $records)
Create an array of new instances of the related model.
at line line 361
string
getHasCompareKey()
Get the key for comparing against the parent key in "has" query.