Relation
abstract class Relation (View source)
Properties
| static protected bool | $has_constraints | Indicates whether the relation is adding constraints. |
|
| static protected bool | $has_pivot | Indicate whether the relationships use a pivot table.*. |
|
| protected string | $foreign_key | The foreign key of the parent model. |
|
| protected string | $primary_key | The associated key on the parent model. |
|
| protected Model | $parent | The parent model instance |
|
| protected Model | $related | The related model instance |
|
| protected QueryBuilder | $query | The Bow Query builder |
|
| protected bool | $eager_has_no_keys | Whether no parent exposed a key during eager loading, in which case the relation resolves to nothing without querying the database. |
Methods
Set the base constraints on the relation query.
Get the results of the relationship.
The parent attribute whose value is matched against the related models.
The related column queried when eager loading the relation.
Whether the relation resolves to many related models.
Get associated model class.
Constrain the relation query to every parent key in a single whereIn.
Execute the eager query and return the related models.
Match the eager loaded related models back onto their parents.
_Call
Details
abstract void
addConstraints()
Set the base constraints on the relation query.
abstract mixed
getResults()
Get the results of the relationship.
abstract protected string
eagerParentKey()
The parent attribute whose value is matched against the related models.
abstract protected string
eagerRelatedKey()
The related column queried when eager loading the relation.
abstract protected bool
eagerIsMany()
Whether the relation resolves to many related models.
Model
getParent()
Get the parent model.
Model
getRelated()
Get associated model class.
Model
create(array $attributes)
Create a new row of the related
static mixed
noConstraints(Closure $callback)
Run the given callback with relation constraints disabled.
Lets the eager loader build a relation without the single parent WHERE clause so it can be replaced by a batched whereIn over every parent.
void
addEagerConstraints(array $parents)
Constrain the relation query to every parent key in a single whereIn.
Collection
getEager()
Execute the eager query and return the related models.
void
match(array $parents, Collection $results, string $name)
Match the eager loaded related models back onto their parents.
mixed
__call(string $method, array $args = [])
_Call