BelongsToMany
class BelongsToMany extends Relation (View source)
Properties
| static protected bool | $has_constraints | Indicates whether the relation is adding constraints. |
from Relation |
| static protected bool | $has_pivot | Indicate whether the relationships use a pivot table.*. |
from Relation |
| protected string | $foreign_key | The foreign key of the parent model. |
from Relation |
| protected string | $primary_key | The associated key on the parent model. |
from Relation |
| protected Model | $parent | The parent model instance |
from Relation |
| protected Model | $related | The related model instance |
from Relation |
| protected QueryBuilder | $query | The Bow Query builder |
from Relation |
| 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. |
from Relation |
Methods
Create a new belongs to relationship instance.
Set the base constraints on the relation query.
Get the results of the relationship.
No description
No description
No description
Constrain the relation query to every parent key in a single whereIn.
Match the eager loaded related models back onto their parents.
Details
__construct(Model $related, Model $parent, string $foreign_key, string $primary_key)
Create a new belongs to relationship instance.
void
addConstraints()
Set the base constraints on the relation query.
mixed
getResults()
Get the results of the relationship.
protected string
eagerParentKey()
No description
protected string
eagerRelatedKey()
No description
protected bool
eagerIsMany()
No description
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