MorphToMany
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
Returns the model query with deferred bindings added
Returns the related "slave id" key in a database friendly format.
Set the defined constraints on the relation query.
Add relation based constraints.
Create a new morph to many relationship instance.
Get the select columns for the relation query.
Save the supplied related model with deferred binding support.
Override sync() method of BelongToMany relation in order to flush the query cache.
Create a new instance of this related model with deferred binding support.
Override attach() method of BelongToMany relation.
Override detach() method of BelongToMany relation.
Adds a model to this relationship type.
Removes a model from this relationship type.
Get a paginator for the "select" statement. Complies with October Rain.
Create a new pivot model instance.
Helper for setting this relationship using various expected values. For example, $model->relation = $value;
Helper for getting this relationship simple value, generally useful with form values.
Get all of the IDs for the related models, with deferred binding support
Set the where clause for the relation query.
Set the constraints for an eager load of the relation.
Create a new pivot attachment record.
Add the constraints for a relationship count query.
Create a new query builder for the pivot table.
Get the foreign key "type" name.
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
in
DeferOneOrMany at line 125
protected Expression
getWithDeferredQualifiedKeyName()
Returns the related "slave id" key in a database friendly format.
in
DefinedConstraints at line 20
void
addDefinedConstraints()
Set the defined constraints on the relation query.
in
DefinedConstraints at line 35
addDefinedConstraintsToRelation(Relation $relation, array $args = null)
Add relation based constraints.
in
DefinedConstraints at line 85
addDefinedConstraintsToQuery(Builder $query, array $args = null)
Add query based constraints.
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.
in
BelongsToMany at line 69
protected BelongsToMany
shouldSelect(array $columns = ['*'])
Get the select columns for the relation query.
in
BelongsToMany at line 89
save(Model $model, array $pivotData = [], $sessionKey = null)
Save the supplied related model with deferred binding support.
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.
in
BelongsToMany at line 112
create(array $attributes = [], array $pivotData = [], $sessionKey = null)
Create a new instance of this related model with deferred binding support.
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
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
in
BelongsToMany at line 224
add(Model $model, $sessionKey = null, $pivotData = [])
Adds a model to this relationship type.
in
BelongsToMany at line 243
remove(Model $model, $sessionKey = null)
Removes a model from this relationship type.
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.
at line 166
Pivot
newPivot(array $attributes = [], bool $exists = false)
Create a new pivot model instance.
in
BelongsToMany at line 302
setSimpleValue($value)
Helper for setting this relationship using various expected values. For example, $model->relation = $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
in
BelongsToMany at line 404
string
getForeignKey()
Get the fully qualified foreign key for the relation.
in
BelongsToMany at line 414
string
getOtherKey()
Get the fully qualified "other key" for the relation.
at line 95
protected $this
addWhereConstraints()
Set the where clause for the relation query.
at line 110
void
addEagerConstraints(array $models)
Set the constraints for an eager load of the relation.
at line 124
protected array
baseAttachRecord(int $id, bool $timed)
Create a new pivot attachment record.
at line 141
Builder
getRelationExistenceQuery(Builder $query, Builder $parentQuery, array|mixed $columns = ['*'])
Add the constraints for a relationship count query.
at line 154
Builder
newPivotQuery()
Create a new query builder for the pivot table.
at line 185
string
getMorphType()
Get the foreign key "type" name.
at line 195
string
getMorphClass()
Get the class name of the parent model.