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
Class | Description |
---|---|
Illuminate\Database\Eloquent\Relations\MorphToMany
|
Traits
Trait | Description |
---|---|
BelongsOrMorphsToMany
|
|
DeferOneOrMany
|
|
DefinedConstraints
|
Properties
inherited
public
$countMode
:
bool
= false
This relation object is a 'count' helper.
inherited
public
$orphanMode
:
bool
= false
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.
Property | Type | Description |
---|---|---|
$query | Illuminate\Database\Eloquent\Builder |
Illuminate\Database\Eloquent\Builder
|
$parent | Illuminate\Database\Eloquent\Model |
Illuminate\Database\Eloquent\Model
|
$name | string |
string
|
$table | string |
string
|
$foreignKey | string |
string
|
$otherKey | string |
string
|
$parentKey | mixed |
mixed
|
$relatedKey | mixed |
mixed
|
$relationName | string |
string
|
$inverse | boolean |
boolean
|
public
newPivot (array $attributes = []
, boolean $exists = false
)
: Illuminate\Database\Eloquent\Relations\Pivot
Create a new pivot model instance.
Property | Type | Description |
---|---|---|
$attributes | array |
array
|
$exists | boolean |
boolean
|
public newPivotQuery () : Illuminate\Database\Query\Builder
Create a new query builder for the pivot table.
inherited
public
add (Illuminate\Database\Eloquent\Model $model, $sessionKey = null
, array $pivotData = []
)
Adds a model to this relationship type.
Property | Type | Description |
---|---|---|
$model | Illuminate\Database\Eloquent\Model |
Illuminate\Database\Eloquent\Model
|
$sessionKey | mixed |
mixed
|
$pivotData | array |
array
|
inherited public addDefinedConstraints () : void
Set the defined constraints on the relation query.
inherited
public
addDefinedConstraintsToQuery (Illuminate\Database\Eloquent\Relations\Relation | Winter\Storm\Database\QueryBuilder $query, array | null $args = null
)
Add query based constraints.
Property | Type | Description |
---|---|---|
$query | Illuminate\Database\Eloquent\Relations\Relation | Winter\Storm\Database\QueryBuilder |
Illuminate\Database\Eloquent\Relations\Relation | Winter\Storm\Database\QueryBuilder
|
$args | array | null |
array | null
|
inherited
public
addDefinedConstraintsToRelation (Illuminate\Database\Eloquent\Relations\Relation $relation, array | null $args = null
)
Add relation based constraints.
Property | Type | Description |
---|---|---|
$relation | Illuminate\Database\Eloquent\Relations\Relation |
Illuminate\Database\Eloquent\Relations\Relation
|
$args | array | null |
array | null
|
inherited
public
allRelatedIds (string $sessionKey = null
)
: Illuminate\Support\Collection
Get all of the IDs for the related models, with deferred binding support
Property | Type | Description |
---|---|---|
$sessionKey | string |
string
|
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
Property | Type | Description |
---|---|---|
$id | mixed |
mixed
|
$attributes | array |
array
|
$touch | boolean |
boolean
|
inherited
public
create (array $attributes = []
, array $pivotData = []
, $sessionKey = null
)
Create a new instance of this related model with deferred binding support.
Property | Type | Description |
---|---|---|
$attributes | array |
array
|
$pivotData | array |
array
|
$sessionKey | mixed |
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
Property | Type | Description |
---|---|---|
$ids | Collection | Model | array | null |
Collection | Model | array | null
|
$touch | boolean |
boolean
|
inherited public getForeignKey () : string
Get the fully qualified foreign key for the relation.
inherited public getOtherKey () : string
Get the fully qualified "other key" for the relation.
inherited
public
getRelatedIds ($sessionKey = null
)
Property | Type | Description |
---|---|---|
$sessionKey | mixed |
mixed
|
inherited public getSimpleValue ()
Helper for getting this relationship simple value, generally useful with form values.
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.
Property | Type | Description |
---|---|---|
$perPage | integer |
integer
|
$currentPage | int |
int
|
$columns | array |
array
|
$pageName | string |
string
|
inherited
public
remove (Illuminate\Database\Eloquent\Model $model, $sessionKey = null
)
Removes a model from this relationship type.
Property | Type | Description |
---|---|---|
$model | Illuminate\Database\Eloquent\Model |
Illuminate\Database\Eloquent\Model
|
$sessionKey | mixed |
mixed
|
inherited
public
save (Illuminate\Database\Eloquent\Model $model, array $pivotData = []
, $sessionKey = null
)
Save the supplied related model with deferred binding support.
Property | Type | Description |
---|---|---|
$model | Illuminate\Database\Eloquent\Model |
Illuminate\Database\Eloquent\Model
|
$pivotData | array |
array
|
$sessionKey | mixed |
mixed
|
inherited public setSimpleValue ($value)
Helper for setting this relationship using various expected values. For example, $model->relation = $value;
Property | Type | Description |
---|---|---|
$value | mixed |
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.
Property | Type | Description |
---|---|---|
$perPage | int | null |
int | null
|
$currentPage | int | null |
int | null
|
$columns | array |
array
|
$pageName | string |
string
|
inherited
public
sync (array $ids, boolean $detaching = true
)
: array
Override sync() method of BelongToMany relation in order to flush the query cache.
Property | Type | Description |
---|---|---|
$ids | array |
array
|
$detaching | boolean |
boolean
|
inherited public withDeferred ($sessionKey) : Illuminate\Database\Eloquent\Builder
Returns the model query with deferred bindings added
Property | Type | Description |
---|---|---|
$sessionKey | mixed |
mixed
|
inherited protected getWithDeferredQualifiedKeyName () : Illuminate\Database\Query\Expression
Returns the related "slave id" key in a database friendly format.
inherited
protected
shouldSelect (array $columns = ["*"]
)
: array | string
Get the select columns for the relation query.
Property | Type | Description |
---|---|---|
$columns | array |
array
|