MorphToMany

Morph To Many relation.

 class Winter\Storm\Database\Relations\MorphToMany
extends Illuminate\Database\Eloquent\Relations\MorphToMany

As of 1.2.0, this relation has been refactored to extend the Eloquent MorphToMany relation, to maintain covariance with Laravel. We instead use the Concerns\BelongsOrMorphsToMany trait to provide base BaseToMany functionality that includes Winter overrides.

Extends

Traits

Properties

inherited public $countMode : bool

This relation object is a 'count' helper.

inherited public $orphanMode : bool

When a join is not used, don't select aliased columns.

Methods

public __construct (Illuminate\Database\Eloquent\Builder $query, Illuminate\Database\Eloquent\Model $parent, string $name, string $table, string $foreignKey, string $otherKey, $parentKey, $relatedKey, string $relationName = null, boolean $inverse = false) : void

Create a new morph to many relationship instance.

Parameters
Property Description
$query
Illuminate\Database\Eloquent\Builder
$parent
Illuminate\Database\Eloquent\Model
$name
string
$table
string
$foreignKey
string
$otherKey
string
$parentKey
mixed
$relatedKey
mixed
$relationName
string
$inverse
boolean
Returns
void

public newPivot (array $attributes = [], boolean $exists = false) : Illuminate\Database\Eloquent\Relations\Pivot

Create a new pivot model instance.

Parameters
Property Description
$attributes
array
$exists
boolean
Returns
Illuminate\Database\Eloquent\Relations\Pivot

public newPivotQuery () : Illuminate\Database\Query\Builder

Create a new query builder for the pivot table.

Returns
Illuminate\Database\Query\Builder

inherited public add (Illuminate\Database\Eloquent\Model $model, $sessionKey = null, array $pivotData = [])

Adds a model to this relationship type.

Parameters
Property Description
$model
Illuminate\Database\Eloquent\Model
$sessionKey
mixed
$pivotData
array
Returns
mixed

inherited public addDefinedConstraints () : void

Inherited from DefinedConstraints

Set the defined constraints on the relation query.

Returns
void

inherited public addDefinedConstraintsToQuery (Illuminate\Database\Eloquent\Relations\Relation | Winter\Storm\Database\QueryBuilder $query, array | null $args = null)

Inherited from DefinedConstraints

Add query based constraints.

Parameters
Property Description
$query
Illuminate\Database\Eloquent\Relations\Relation | Winter\Storm\Database\QueryBuilder
$args
array | null
Returns
mixed

inherited public addDefinedConstraintsToRelation (Illuminate\Database\Eloquent\Relations\Relation $relation, array | null $args = null)

Inherited from DefinedConstraints

Add relation based constraints.

Parameters
Property Description
$relation
Illuminate\Database\Eloquent\Relations\Relation
$args
array | null
Returns
mixed

inherited public allRelatedIds (string $sessionKey = null) : Illuminate\Support\Collection

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

Parameters
Property Description
$sessionKey
string
Returns
Illuminate\Support\Collection

inherited public attach (mixed $id, array $attributes = [], boolean $touch = true)

Override attach() method of BelongToMany relation.

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

Parameters
Property Description
$id
mixed
$attributes
array
$touch
boolean
Returns
mixed

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

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

Parameters
Property Description
$attributes
array
$pivotData
array
$sessionKey
mixed
Returns
mixed

inherited public detach (Collection | Model | array | null $ids = null, boolean $touch = true) : int | void

Override detach() method of BelongToMany relation.

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

Parameters
Property Description
$ids
Collection | Model | array | null
$touch
boolean
Returns
int | void

inherited public getForeignKey () : string

Get the fully qualified foreign key for the relation.

Returns
string

inherited public getOtherKey () : string

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

Returns
string

inherited public getRelatedIds ($sessionKey = null)

Parameters
Property Description
$sessionKey
mixed
Returns
mixed

inherited public getSimpleValue ()

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

Returns
mixed

inherited public paginate (integer $perPage = 15, int $currentPage = null, array $columns = ["*"], string $pageName = "page") : Illuminate\Contracts\Pagination\LengthAwarePaginator

Get a paginator for the "select" statement. Complies with Winter Storm.

Parameters
Property Description
$perPage
integer
$currentPage
int
$columns
array
$pageName
string
Returns
Illuminate\Contracts\Pagination\LengthAwarePaginator

inherited public remove (Illuminate\Database\Eloquent\Model $model, $sessionKey = null)

Removes a model from this relationship type.

Parameters
Property Description
$model
Illuminate\Database\Eloquent\Model
$sessionKey
mixed
Returns
mixed

inherited public save (Illuminate\Database\Eloquent\Model $model, array $pivotData = [], $sessionKey = null)

Save the supplied related model with deferred binding support.

Parameters
Property Description
$model
Illuminate\Database\Eloquent\Model
$pivotData
array
$sessionKey
mixed
Returns
mixed

inherited public setSimpleValue ($value)

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

Parameters
Property Description
$value
mixed
Returns
mixed

inherited public simplePaginate (int | null $perPage = null, int | null $currentPage = null, array $columns = ["*"], string $pageName = "page") : Illuminate\Contracts\Pagination\Paginator

Paginate the given query into a simple paginator.

Parameters
Property Description
$perPage
int | null
$currentPage
int | null
$columns
array
$pageName
string
Returns
Illuminate\Contracts\Pagination\Paginator

inherited public sync (array $ids, boolean $detaching = true) : array

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

Parameters
Property Description
$ids
array
$detaching
boolean
Returns
array

inherited public withDeferred ($sessionKey) : Illuminate\Database\Eloquent\Builder

Inherited from DeferOneOrMany

Returns the model query with deferred bindings added

Parameters
Property Description
$sessionKey
mixed
Returns
Illuminate\Database\Eloquent\Builder

inherited protected getWithDeferredQualifiedKeyName () : Illuminate\Database\Query\Expression

Inherited from DeferOneOrMany

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

Returns
Illuminate\Database\Query\Expression

inherited protected shouldSelect (array $columns = ["*"]) : array | string

Get the select columns for the relation query.

Parameters
Property Description
$columns
array
Returns
array | string
Copyright © 2024 Winter CMS