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
$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

__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.

string
eagerParentKey()

No description

string
eagerRelatedKey()

No description

bool
eagerIsMany()

No description

getParent()

Get the parent model.

from  Relation
getRelated()

Get associated model class.

from  Relation
create(array $attributes)

Create a new row of the related

from  Relation
static mixed
noConstraints(Closure $callback)

Run the given callback with relation constraints disabled.

from  Relation
void
addEagerConstraints(array $parents)

Constrain the relation query to every parent key in a single whereIn.

from  Relation
getEager()

Execute the eager query and return the related models.

from  Relation
void
match(array $parents, Collection $results, string $name)

Match the eager loaded related models back onto their parents.

from  Relation
mixed
__call(string $method, array $args = [])

_Call

from  Relation

Details

__construct(Model $related, Model $parent, string $foreign_key, string $primary_key)

Create a new belongs to relationship instance.

Parameters

Model $related
Model $parent
string $foreign_key
string $primary_key

void addConstraints()

Set the base constraints on the relation query.

Return Value

void

Exceptions

QueryBuilderException

mixed getResults()

Get the results of the relationship.

Return Value

mixed

protected string eagerParentKey()

No description

Return Value

string

protected string eagerRelatedKey()

No description

Return Value

string

protected bool eagerIsMany()

No description

Return Value

bool

Model getParent()

Get the parent model.

Return Value

Model

Model getRelated()

Get associated model class.

Return Value

Model

Model create(array $attributes)

Create a new row of the related

Parameters

array $attributes

Return Value

Model

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.

Parameters

Closure $callback

Return Value

mixed

void addEagerConstraints(array $parents)

Constrain the relation query to every parent key in a single whereIn.

Parameters

array $parents

Return Value

void

Collection getEager()

Execute the eager query and return the related models.

Return Value

Collection

void match(array $parents, Collection $results, string $name)

Match the eager loaded related models back onto their parents.

Parameters

array $parents
Collection $results
string $name

Return Value

void

mixed __call(string $method, array $args = [])

_Call

Parameters

string $method
array $args

Return Value

mixed