BelongsTo
class BelongsTo extends Relation (View source)
Methods
Create a new belongs to 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.
Get the results of the relationship.
Add the constraints for a relationship count query.
Add the constraints for a 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.
Get a relationship join table hash.
Dissociate previously associated model from the given parent.
Update the parent model on the relationship.
Get the foreign key of the relationship.
Get the fully qualified foreign key of the relationship.
Get the associated key of the relationship.
Get the fully qualified associated key of the relationship.
Details
at line line 43
void
__construct(
Builder $query,
Model $parent,
string $foreignKey,
string $otherKey,
string $relation)
Create a new belongs to relationship instance.
at line line 137
void
addEagerConstraints(
array $models)
Set the constraints for an eager load of the relation.
at line line 183
array
initRelation(
array $models,
string $relation)
Initialize the relation on a set of models.
at line line 200
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 87
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 108
Builder
getRelationQueryForSelfRelation(
Builder $query,
Builder $parent,
array|mixed $columns = array('*'))
Add the constraints for a relationship query on the same table.
at line line 233
Model
associate(
Model|int $model)
Associate the model instance to the given parent.
at line line 286
string
getQualifiedForeignKey()
Get the fully qualified foreign key of the relationship.
at line line 306
string
getQualifiedOtherKeyName()
Get the fully qualified associated key of the relationship.