class BelongsToMany extends BelongsToMany

Adapted from october\rain\database\relations\BelongsToMany

Traits

Adapted from october\rain\database\relations\DeferOneOrMany

Properties

bool $countMode
bool $orphanMode

Methods

Builder
withDeferred($sessionKey)

Returns the model query with deferred bindings added

Expression
getWithDeferredQualifiedKeyName()

Returns the related "slave id" key in a database friendly format.

void
addDefinedConstraints()

Set the defined constraints on the relation query.

addDefinedConstraintsToRelation(Relation $relation, array $args = null)

Add relation based constraints.

addDefinedConstraintsToQuery(Builder $query, array $args = null)

Add query based constraints.

void
__construct(Builder $query, Model $parent, string $table, string $foreignPivotKey, string $relatedPivotKey, $parentKey, $relatedKey, string $relationName = null)

Create a new belongs to many relationship instance.

BelongsToMany
shouldSelect(array $columns = ['*'])

Get the select columns for the relation query.

save(Model $model, array $pivotData = [], $sessionKey = null)

Save the supplied related model with deferred binding support.

array
sync(array $ids, bool $detaching = true)

Override sync() method of BelongToMany relation in order to flush the query cache.

create(array $attributes = [], array $pivotData = [], $sessionKey = null)

Create a new instance of this related model with deferred binding support.

attach(mixed $id, array $attributes = [], bool $touch = true)

Override attach() method of BelongToMany relation.

int|void
detach(null $ids = null, bool $touch = true)

Override detach() method of BelongToMany relation.

add(Model $model, $sessionKey = null, $pivotData = [])

Adds a model to this relationship type.

remove(Model $model, $sessionKey = null)

Removes a model from this relationship type.

LengthAwarePaginator
paginate(int $perPage = 15, int $currentPage = null, array $columns = ['*'], string $pageName = 'page')

Get a paginator for the "select" statement. Complies with October Rain.

Pivot
newPivot(array $attributes = [], bool $exists = false)

Create a new pivot model instance.

setSimpleValue($value)

Helper for setting this relationship using various expected values. For example, $model->relation = $value;

getSimpleValue()

Helper for getting this relationship simple value, generally useful with form values.

Collection
allRelatedIds(string $sessionKey = null)

Get all of the IDs for the related models, with deferred binding support

string
getForeignKey()

Get the fully qualified foreign key for the relation.

string
getOtherKey()

Get the fully qualified "other key" for the relation.

Details

in DeferOneOrMany at line 17
Builder withDeferred($sessionKey)

Returns the model query with deferred bindings added

Parameters

$sessionKey

Return Value

Builder

in DeferOneOrMany at line 125
protected Expression getWithDeferredQualifiedKeyName()

Returns the related "slave id" key in a database friendly format.

Return Value

Expression

in DefinedConstraints at line 20
void addDefinedConstraints()

Set the defined constraints on the relation query.

Return Value

void

in DefinedConstraints at line 35
addDefinedConstraintsToRelation(Relation $relation, array $args = null)

Add relation based constraints.

Parameters

Relation $relation
array $args

in DefinedConstraints at line 85
addDefinedConstraintsToQuery(Builder $query, array $args = null)

Add query based constraints.

Parameters

Builder $query
array $args

at line 39
void __construct(Builder $query, Model $parent, string $table, string $foreignPivotKey, string $relatedPivotKey, $parentKey, $relatedKey, string $relationName = null)

Create a new belongs to many relationship instance.

Parameters

Builder $query
Model $parent
string $table
string $foreignPivotKey
string $relatedPivotKey
$parentKey
$relatedKey
string $relationName

Return Value

void

at line 69
protected BelongsToMany shouldSelect(array $columns = ['*'])

Get the select columns for the relation query.

Parameters

array $columns

Return Value

BelongsToMany

at line 89
save(Model $model, array $pivotData = [], $sessionKey = null)

Save the supplied related model with deferred binding support.

Parameters

Model $model
array $pivotData
$sessionKey

at line 103
array sync(array $ids, bool $detaching = true)

Override sync() method of BelongToMany relation in order to flush the query cache.

Parameters

array $ids
bool $detaching

Return Value

array

at line 112
create(array $attributes = [], array $pivotData = [], $sessionKey = null)

Create a new instance of this related model with deferred binding support.

Parameters

array $attributes
array $pivotData
$sessionKey

at line 128
attach(mixed $id, array $attributes = [], bool $touch = true)

Override attach() method of BelongToMany relation.

This is necessary in order to fire 'model.relation.beforeAttach', 'model.relation.afterAttach' events

Parameters

mixed $id
array $attributes
bool $touch

at line 179
int|void detach(null $ids = null, bool $touch = true)

Override detach() method of BelongToMany relation.

This is necessary in order to fire 'model.relation.beforeDetach', 'model.relation.afterDetach' events

Parameters

null $ids
bool $touch

Return Value

int|void

at line 224
add(Model $model, $sessionKey = null, $pivotData = [])

Adds a model to this relationship type.

Parameters

Model $model
$sessionKey
$pivotData

at line 243
remove(Model $model, $sessionKey = null)

Removes a model from this relationship type.

Parameters

Model $model
$sessionKey

at line 263
LengthAwarePaginator paginate(int $perPage = 15, int $currentPage = null, array $columns = ['*'], string $pageName = 'page')

Get a paginator for the "select" statement. Complies with October Rain.

Parameters

int $perPage
int $currentPage
array $columns
string $pageName

Return Value

LengthAwarePaginator

at line 281
Pivot newPivot(array $attributes = [], bool $exists = false)

Create a new pivot model instance.

Parameters

array $attributes
bool $exists

Return Value

Pivot

at line 302
setSimpleValue($value)

Helper for setting this relationship using various expected values. For example, $model->relation = $value;

Parameters

$value

at line 362
getSimpleValue()

Helper for getting this relationship simple value, generally useful with form values.

at line 388
Collection allRelatedIds(string $sessionKey = null)

Get all of the IDs for the related models, with deferred binding support

Parameters

string $sessionKey

Return Value

Collection

at line 404
string getForeignKey()

Get the fully qualified foreign key for the relation.

Return Value

string

at line 414
string getOtherKey()

Get the fully qualified "other key" for the relation.

Return Value

string