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.
Traits
Trait | Description |
---|---|
BelongsOrMorphsToMany
|
|
DeferOneOrMany
|
|
DefinedConstraints
|
Properties
public
$countMode
:
bool
= false
This relation object is a 'count' helper.
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.
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
|
public addDefinedConstraints () : void
Set the defined constraints on the relation query.
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
|
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
|
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
|
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
|
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
|
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
|
public getForeignKey () : string
Get the fully qualified foreign key for the relation.
public getOtherKey () : string
Get the fully qualified "other key" for the relation.
public
getRelatedIds ($sessionKey = null
)
Property | Type | Description |
---|---|---|
$sessionKey | mixed |
mixed
|
public getSimpleValue ()
Helper for getting this relationship simple value, generally useful with form values.
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
|
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
|
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
|
public setSimpleValue ($value)
Helper for setting this relationship using various expected values. For example, $model->relation = $value;
Property | Type | Description |
---|---|---|
$value | mixed |
mixed
|
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
|
public withDeferred ($sessionKey) : Illuminate\Database\Eloquent\Builder
Returns the model query with deferred bindings added
Property | Type | Description |
---|---|---|
$sessionKey | mixed |
mixed
|
protected getWithDeferredQualifiedKeyName () : Illuminate\Database\Query\Expression
Returns the related "slave id" key in a database friendly format.
protected
shouldSelect (array $columns = ["*"]
)
: array | string
Get the select columns for the relation query.
Property | Type | Description |
---|---|---|
$columns | array |
array
|