class MorphToMany extends BelongsToMany

Morph to many

This class is a carbon copy of Illuminate\Database\Eloquent\Relations\MorphToMany so the base Igniter\Flame\Database\Relations\BelongsToMany class can be inherited

Adapted from october\rain\database\relations\MorphToMany

Traits

Adapted from october\rain\database\relations\DeferOneOrMany

Properties

bool $countMode from  BelongsToMany
bool $orphanMode from  BelongsToMany
protected string $morphType

The type of the polymorphic relation.

protected string $morphClass

The class name of the morph type constraint.

protected bool $inverse

Indicates if we are connecting the inverse of the relation.

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 $name, string $table, string $foreignKey, string $otherKey, $parentKey, $relatedKey, string $relationName = null, bool $inverse = false)

Create a new morph 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.

$this
addWhereConstraints()

Set the where clause for the relation query.

void
addEagerConstraints(array $models)

Set the constraints for an eager load of the relation.

array
baseAttachRecord(int $id, bool $timed)

Create a new pivot attachment record.

Builder
getRelationExistenceQuery(Builder $query, Builder $parentQuery, array|mixed $columns = ['*'])

Add the constraints for a relationship count query.

Builder
newPivotQuery()

Create a new query builder for the pivot table.

string
getMorphType()

Get the foreign key "type" name.

string
getMorphClass()

Get the class name of the parent model.

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 58
void __construct(Builder $query, Model $parent, string $name, string $table, string $foreignKey, string $otherKey, $parentKey, $relatedKey, string $relationName = null, bool $inverse = false)

Create a new morph to many relationship instance.

Parameters

Builder $query
Model $parent
string $name
string $table
string $foreignKey
string $otherKey
$parentKey
$relatedKey
string $relationName
bool $inverse

Return Value

void

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

Get the select columns for the relation query.

Parameters

array $columns

Return Value

BelongsToMany

in 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

in BelongsToMany 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

in BelongsToMany 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

in BelongsToMany 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

in BelongsToMany 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

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

Adds a model to this relationship type.

Parameters

Model $model
$sessionKey
$pivotData

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

Removes a model from this relationship type.

Parameters

Model $model
$sessionKey

in BelongsToMany 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 166
Pivot newPivot(array $attributes = [], bool $exists = false)

Create a new pivot model instance.

Parameters

array $attributes
bool $exists

Return Value

Pivot

in BelongsToMany at line 302
setSimpleValue($value)

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

Parameters

$value

in BelongsToMany at line 362
getSimpleValue()

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

in BelongsToMany 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

in BelongsToMany at line 404
string getForeignKey()

Get the fully qualified foreign key for the relation.

Return Value

string

in BelongsToMany at line 414
string getOtherKey()

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

Return Value

string

at line 95
protected $this addWhereConstraints()

Set the where clause for the relation query.

Return Value

$this

at line 110
void addEagerConstraints(array $models)

Set the constraints for an eager load of the relation.

Parameters

array $models

Return Value

void

at line 124
protected array baseAttachRecord(int $id, bool $timed)

Create a new pivot attachment record.

Parameters

int $id
bool $timed

Return Value

array

at line 141
Builder getRelationExistenceQuery(Builder $query, Builder $parentQuery, array|mixed $columns = ['*'])

Add the constraints for a relationship count query.

Parameters

Builder $query
Builder $parentQuery
array|mixed $columns

Return Value

Builder

at line 154
Builder newPivotQuery()

Create a new query builder for the pivot table.

Return Value

Builder

at line 185
string getMorphType()

Get the foreign key "type" name.

Return Value

string

at line 195
string getMorphClass()

Get the class name of the parent model.

Return Value

string