class PartitionedMorphToMany extends MorphToMany

Traits

Constants

protected CONSTRAINTS_CONTEXT_KEY

The context key for storing whether constraints are enabled.

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected TRelatedModel> $query

The Eloquent query builder instance.

from  Relation
protected TDeclaringModel $parent

The parent model instance.

from  Relation
$related

The related model instance.

from  Relation
protected bool $eagerKeysWereEmpty

Indicates whether the eagerly loaded relation should implicitly return an empty collection.

from  Relation
static Model>> $morphMap

An array to map morph names to their class names in the database.

from  Relation
static protected bool $requireMorphMap

Prevents morph relationships without a morph map.

from  Relation
static protected int $selfJoinCount

The count of self joins.

from  Relation
protected string $table

The intermediate table for the relation.

from  BelongsToMany
protected string $foreignPivotKey

The foreign key of the parent model.

from  BelongsToMany
protected string $relatedPivotKey

The associated key of the relation.

from  BelongsToMany
protected string $parentKey

The key name of the parent model.

from  BelongsToMany
protected string $relatedKey

The key name of the related model.

from  BelongsToMany
protected string|null $relationName

The "name" of the relationship.

from  BelongsToMany
protected Expression|string> $pivotColumns

The pivot table columns to retrieve.

from  BelongsToMany
protected array $pivotWheres

Any pivot table restrictions for where clauses.

from  BelongsToMany
protected array $pivotWhereIns

Any pivot table restrictions for whereIn clauses.

from  BelongsToMany
protected array $pivotWhereNulls

Any pivot table restrictions for whereNull clauses.

from  BelongsToMany
protected array $pivotValues

The default values for the pivot columns.

from  BelongsToMany
bool $withTimestamps

Indicates if timestamps are available on the pivot table.

from  BelongsToMany
protected string|null $pivotCreatedAt

The custom pivot table column for the created_at timestamp.

from  BelongsToMany
protected string|null $pivotUpdatedAt

The custom pivot table column for the updated_at timestamp.

from  BelongsToMany
protected null|TPivotModel> $using

The class name of the custom pivot model to use for the relationship.

from  BelongsToMany
protected TAccessor $accessor

The name of the accessor to use for the "pivot" relationship.

from  BelongsToMany
protected string $morphType

The type of the polymorphic relation.

from  MorphToMany
protected TRelatedModel> $morphClass

The class name of the morph type constraint.

from  MorphToMany
protected bool $inverse

Indicates if we are connecting the inverse of the relation.

from  MorphToMany
protected PermissionRegistrar $permissionPartitionRegistrar from  EnforcesPermissionPartition
protected PermissionRelationContext $permissionRelationContext from  EnforcesPermissionPartition

Methods

mixed
forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

mixed
forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

static never
throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

__construct(Builder $query, Model $parent, string $name, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string|null $relationName, bool $inverse, PermissionRegistrar $registrar, PermissionRelationContext $context)

Create a partition-aware morph-to-many relation.

static mixed
noConstraints(Closure $callback)

Run a callback with constraints disabled on the relation.

from  Relation
static bool
shouldAddConstraints()

Determine if constraints should be added to the relation query.

from  Relation
void
addConstraints()

Set the base constraints on the relation query.

void
addEagerConstraints(array $models)

Set the constraints for an eager load of the relation.

array
initRelation(array $models, string $relation)

Initialize and mark eager-loaded relation collections.

array
match(array $models, Collection $results, string $relation)

Match and mark eager-loaded relation collections.

getResults()

Get and mark lazily loaded relation results.

getEager()

Get the relationship for eager loading.

from  Relation
sole(array|string $columns = ['*'])

Execute the query and get the first result if it's the sole matching record.

from  Relation
get(array $columns = ['*'])

Execute the query as a "select" statement.

void
touch()

Touch all of the related models for the relationship.

int
rawUpdate(array $attributes = [])

Run a raw update against the base query.

from  Relation
getRelationExistenceCountQuery(Builder $query, Builder $parentQuery)

Add the constraints for a relationship count query.

from  Relation
getRelationExistenceQuery(Builder $query, Builder $parentQuery, mixed $columns = ['*'])

Add the constraints for an internal relationship existence query.

string
getRelationCountHash(bool $incrementJoinCount = true)

Get a relationship join table hash.

from  Relation
array
getKeys(array $models, string|null $key = null)

Get all of the primary keys for an array of models.

from  Relation
getRelationQuery()

Get the query builder that will contain the relationship constraints.

from  Relation
getQuery()

Get the underlying query for the relation.

from  Relation
getBaseQuery()

Get the base query builder driving the Eloquent builder.

from  Relation
toBase()

Get a base query builder instance.

from  Relation
getParent()

Get the parent model of the relation.

from  Relation
string
getQualifiedParentKeyName()

Get the fully qualified parent key name for the relation.

getRelated()

Get the related model of the relation.

from  Relation
string
createdAt()

Get the name of the "created at" column.

string
updatedAt()

Get the name of the "updated at" column.

string
relatedUpdatedAt()

Get the name of the related model's "updated at" column.

from  Relation
void
whereInEager(string $whereIn, string $key, array $modelKeys, Builder|null $query = null)

Add a whereIn eager constraint for the given set of model keys to be loaded.

from  Relation
string
whereInMethod(Model $model, string $key)

Get the name of the "where in" method for eager loading.

from  Relation
static void
requireMorphMap(bool $requireMorphMap = true)

Prevent polymorphic relationships from being used without model mappings.

from  Relation
static bool
requiresMorphMap()

Determine if polymorphic relationships require explicit model mapping.

from  Relation
static array
enforceMorphMap(array $map, bool $merge = true)

Define the morph map for polymorphic relations and require all morphed models to be explicitly mapped.

from  Relation
static array
morphMap(array|null $map = null, bool $merge = true)

Set or get the morph map for polymorphic relations.

from  Relation
static array|null
buildMorphMapFromModels(array|null $models = null)

Builds a table-keyed array from model class names.

from  Relation
static string|null
getMorphedModel(string $alias)

Get the model associated with a custom polymorphic type.

from  Relation
static int|string
getMorphAlias(string $className)

Get the alias associated with a custom polymorphic class.

from  Relation
static void
flushState()

Flush all static state.

from  Relation
void
__clone()

Force a clone of the underlying query builder when cloning.

from  Relation
mixed
getDictionaryKey(mixed $attribute)

Get a dictionary key attribute - casting it to a string if necessary.

array
toggle(mixed $ids, bool $touch = true)

Toggles a model (or models) from the parent.

array
toggleOrFail(mixed $ids, bool $touch = true)

Toggle a model (or models) from the parent within a transaction.

array
syncWithoutDetaching(Collection|Model|array|int|string|null $ids)

Sync the intermediate tables with a list of IDs without detaching.

array
syncWithoutDetachingOrFail(Collection|Model|array|int|string|null $ids)

Sync the intermediate tables with a list of IDs without detaching within a transaction.

array
sync(Collection|Model|array|int|string|null $ids, bool $detaching = true)

Sync the intermediate tables with a list of IDs or collection of models.

array
syncOrFail(Collection|Model|array|int|string|null $ids, bool $detaching = true)

Sync the intermediate tables with a list of IDs or collection of models within a transaction.

array
syncWithPivotValues(Collection|Model|array|int|string|null $ids, array $values, bool $detaching = true)

Sync the intermediate tables with a list of IDs or collection of models with the given pivot values.

array
syncWithPivotValuesOrFail(Collection|Model|array|int|string|null $ids, array $values, bool $detaching = true)

Sync the intermediate tables with a list of IDs or collection of models with the given pivot values within a transaction.

array
formatRecordsList(array $records)

Format the sync / toggle record list so that it is keyed by ID.

array
attachNew(array $records, array $current, bool $touch = true)

Attach all of the records that aren't in the given current records.

int
updateExistingPivot(mixed $id, array $attributes, bool $touch = true)

Update an existing pivot record on the table.

int
updateExistingPivotOrFail(mixed $id, array $attributes, bool $touch = true)

Update an existing pivot record on the table within a transaction.

int
updateExistingPivotUsingCustomClass(mixed $id, array $attributes, bool $touch)

Update an existing pivot record on the table via a custom class.

void
attach(mixed $ids, array $attributes = [], bool $touch = true)

Attach a model to the parent.

void
attachOrFail(mixed $ids, array $attributes = [], bool $touch = true)

Attach a model to the parent within a transaction.

void
attachUsingCustomClass(mixed $ids, array $attributes)

Attach a model to the parent using a custom class.

array
formatAttachRecords(array $ids, array $attributes)

Create an array of records to insert into the pivot table.

array
formatAttachRecord(int|string $key, mixed $value, array $attributes, bool $hasTimestamps)

Create a full attachment record payload.

array
extractAttachIdAndAttributes(mixed $key, mixed $value, array $attributes)

Get the attach record ID and extra attributes.

array
baseAttachRecord(mixed $id, bool $timed)

Create a new pivot attachment record.

array
addTimestampsToAttachment(array $record, bool $exists = false)

Set the creation and update timestamps on an attach record.

bool
hasPivotColumn(string|null $column)

Determine whether the given column is defined as a pivot column.

int
detach(mixed $ids = null, bool $touch = true)

Detach models from the relationship.

int
detachOrFail(mixed $ids = null, bool $touch = true)

Detach models from the relationship within a transaction.

int
detachUsingCustomClass(mixed $ids)

Detach models from the relationship using a custom class.

getCurrentlyAttachedPivots()

Get the pivot models that are currently attached.

getCurrentlyAttachedPivotsForIds(mixed $ids = null)

Get the pivot models that are currently attached, filtered by related model keys.

newPivot(array $attributes = [], bool $exists = false)

Create a new pivot model instance.

newExistingPivot(array $attributes = [])

Create a new existing pivot model instance.

newPivotStatement()

Get a new plain query builder for the pivot table.

newPivotStatementForId(mixed $id)

Get a new pivot statement for a given "other" ID.

newPivotQuery()

Create a new query builder for the pivot table.

withPivot(mixed $columns)

Set the columns on the pivot table to retrieve.

array
parseIds(mixed $value)

Get all of the IDs from the given mixed value.

mixed
parseId(mixed $value)

Get the ID from the given mixed value.

array
castKeys(array $keys)

Cast the given keys to integers if they are numeric and string otherwise.

mixed
castKey(mixed $key)

Cast the given key to convert to primary key type.

array
castAttributes(array $attributes)

Cast the given pivot attributes.

mixed
getTypeSwapValue(string $type, mixed $value)

Converts a given value to a given type value.

string
resolveTableName(string $table)

Attempt to resolve the intermediate table name from the given string.

performJoin(Builder|null $query = null)

Set the join clause for the relation query.

addWhereConstraints()

Set the where clause for the relation query.

array
buildDictionary(Collection $results)

Build model dictionary keyed by the relation's foreign key.

string
getPivotClass()

Get the class being used for pivot models.

using(string $class)

Specify the custom pivot model to use for the relationship.

as(string $accessor)

Specify the custom pivot accessor to use for the relationship.

wherePivot(mixed $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Set a where clause for a pivot table column.

wherePivotBetween(mixed $column, array $values, string $boolean = 'and', bool $not = false)

Set a "where between" clause for a pivot table column.

orWherePivotBetween(mixed $column, array $values)

Set a "or where between" clause for a pivot table column.

wherePivotNotBetween(mixed $column, array $values, string $boolean = 'and')

Set a "where pivot not between" clause for a pivot table column.

orWherePivotNotBetween(mixed $column, array $values)

Set a "or where not between" clause for a pivot table column.

wherePivotIn(mixed $column, mixed $values, string $boolean = 'and', bool $not = false)

Set a "where in" clause for a pivot table column.

orWherePivot(mixed $column, mixed $operator = null, mixed $value = null)

Set an "or where" clause for a pivot table column.

withPivotValue(mixed $column, mixed $value = null)

Set a where clause for a pivot table column.

orWherePivotIn(string $column, mixed $values)

Set an "or where in" clause for a pivot table column.

wherePivotNotIn(mixed $column, mixed $values, string $boolean = 'and')

Set a "where not in" clause for a pivot table column.

orWherePivotNotIn(string $column, mixed $values)

Set an "or where not in" clause for a pivot table column.

wherePivotNull(mixed $column, string $boolean = 'and', bool $not = false)

Set a "where null" clause for a pivot table column.

wherePivotNotNull(mixed $column, string $boolean = 'and')

Set a "where not null" clause for a pivot table column.

orWherePivotNull(mixed $column, bool $not = false)

Set a "or where null" clause for a pivot table column.

orWherePivotNotNull(mixed $column)

Set a "or where not null" clause for a pivot table column.

orderByPivot(mixed $column, SortDirection|string $direction = SortDirection::Ascending)

Add an "order by" clause for a pivot table column.

orderByPivotDesc(mixed $column)

Add an "order by desc" clause for a pivot table column.

findOrNew(mixed $id, array $columns = ['*'])

Find a related model by its primary key or return a new instance of the related model.

firstOrNew(array $attributes = [], Closure|array $values = [])

Get the first related model record matching the attributes or instantiate it.

firstOrCreate(array $attributes = [], Closure|array $values = [], array $joining = [], bool $touch = true)

Get the first record matching the attributes. If the record is not found, create it.

createOrFirst(array $attributes = [], Closure|array $values = [], array $joining = [], bool $touch = true)

Attempt to create the record. If a unique constraint violation occurs, attempt to find the matching record.

updateOrCreate(array $attributes, Closure|array $values = [], array $joining = [], bool $touch = true)

Create or update a related record matching the attributes, and fill it with values.

find(mixed $id, array $columns = ['*'])

Find a related model by its primary key.

findSole(mixed $id, array $columns = ['*'])

Find a sole related model by its primary key.

findMany(Arrayable|array $ids, array $columns = ['*'])

Find multiple related models by their primary keys.

findOrFail(mixed $id, array $columns = ['*'])

Find a related model by its primary key or throw an exception.

mixed
findOr(mixed $id, Closure|array|string $columns = ['*'], Closure|null $callback = null)

Find a related model by its primary key or call a callback.

Model|null
firstWhere(Closure|string|array $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Add a basic where clause to the query, and return the first result.

Model|null
first(array $columns = ['*'])

Execute the query and get the first result.

firstOrFail(array $columns = ['*'])

Execute the query and get the first result or throw an exception.

mixed
firstOr(Closure|array $columns = ['*'], Closure|null $callback = null)

Execute the query and get the first result or call a callback.

array
shouldSelect(array $columns = ['*'])

Get the select columns for the relation query.

array
aliasedPivotColumns()

Get the pivot columns for the relation.

mixed
paginate(int|null $perPage = null, array $columns = ['*'], string $pageName = 'page', int|null $page = null)

Get a paginator for the "select" statement.

mixed
simplePaginate(int|null $perPage = null, array $columns = ['*'], string $pageName = 'page', int|null $page = null)

Paginate the given query into a simple paginator.

mixed
cursorPaginate(int|null $perPage = null, array $columns = ['*'], string $cursorName = 'cursor', string|null $cursor = null)

Paginate the given query into a cursor paginator.

bool
chunk(int $count, callable $callback)

Chunk the results of the query.

bool
chunkById(int $count, callable $callback, string|null $column = null, string|null $alias = null)

Chunk the results of a query by comparing numeric IDs.

bool
chunkByIdDesc(int $count, callable $callback, string|null $column = null, string|null $alias = null)

Chunk the results of a query by comparing IDs in descending order.

bool
eachById(callable $callback, int $count = 1000, string|null $column = null, string|null $alias = null)

Execute a callback over each item while chunking by ID.

bool
orderedChunkById(int $count, callable $callback, string|null $column = null, string|null $alias = null, SortDirection|bool $descending = false)

Chunk the results of a query by comparing IDs in a given order.

bool
each(callable $callback, int $count = 1000)

Execute a callback over each item while chunking.

mixed
lazy(int $chunkSize = 1000)

Query lazily, by chunks of the given size.

mixed
lazyById(int $chunkSize = 1000, string|null $column = null, string|null $alias = null)

Query lazily, by chunking the results of a query by comparing IDs.

mixed
lazyByIdDesc(int $chunkSize = 1000, string|null $column = null, string|null $alias = null)

Query lazily, by chunking the results of a query by comparing IDs in descending order.

mixed
cursor()

Get a lazy collection for the given query.

prepareQueryBuilder()

Prepare the query builder for query execution.

void
hydratePivotRelation(array $models)

Hydrate the pivot table relationship on the models.

array
migratePivotAttributes(Model $model)

Get the pivot attributes from a model.

void
touchIfTouching()

If we're touching the parent model, touch.

bool
touchingParent()

Determine if we should touch the parent on sync.

string
guessInverseRelation()

Attempt to guess the name of the inverse of the relation.

allRelatedIds()

Get all of the IDs for the related models.

save(Model $model, array $pivotAttributes = [], bool $touch = true)

Save a new model and attach it to the parent model.

saveQuietly(Model $model, array $pivotAttributes = [], bool $touch = true)

Save a new model without raising any events and attach it to the parent model.

iterable
saveMany(iterable $models, array $pivotAttributes = [])

Save an array of new models and attach them to the parent model.

iterable
saveManyQuietly(iterable $models, array $pivotAttributes = [])

Save an array of new models without raising any events and attach them to the parent model.

create(array $attributes = [], array $joining = [], bool $touch = true)

Create a new instance of the related model.

array
createMany(iterable $records, array $joinings = [])

Create an array of new instances of the related models.

getRelationExistenceQueryForSelfJoin(Builder $query, Builder $parentQuery, mixed $columns = ['*'])

Add the constraints for a relationship query on the same table.

take(int $value)

Alias to set the "limit" value of the query.

limit(int $value)

Set the "limit" value of the query.

string
getExistenceCompareKey()

Get the key for comparing against the parent key in "has" query.

withTimestamps(string|false|null $createdAt = null, string|false|null $updatedAt = null)

Specify that the pivot table has creation and update timestamps.

string
getForeignPivotKeyName()

Get the foreign key for the relation.

string
getQualifiedForeignPivotKeyName()

Get the fully qualified foreign key for the relation.

string
getRelatedPivotKeyName()

Get the "related key" for the relation.

string
getQualifiedRelatedPivotKeyName()

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

string
getParentKeyName()

Get the parent key for the relationship.

string
getRelatedKeyName()

Get the related key for the relationship.

string
getQualifiedRelatedKeyName()

Get the fully qualified related key name for the relation.

string
getTable()

Get the intermediate table for the relationship.

string|null
getRelationName()

Get the relationship name for the relationship.

string
getPivotAccessor()

Get the name of the pivot accessor for this relationship.

array
getPivotColumns()

Get the pivot columns for this relationship.

mixed
qualifyPivotColumn(mixed $column)

Qualify the given column name by the pivot table.

string
getMorphType()

Get the foreign key "type" name.

string
getQualifiedMorphTypeName()

Get the fully qualified morph type for the relation.

string
getMorphClass()

Get the class name of the parent model.

bool
getInverse()

Get the indicator for a reverse relationship.

void
initializePermissionPartitionRelation(PermissionRegistrar $registrar, PermissionRelationContext $context)

Initialize the permission partition relation state.

void
ensurePivotMatchesPermissionPartition(array $attributes)

Reject conflicting caller-supplied partition attributes.

void
markPermissionRelationCollections(array $models, string $relation)

Mark the loaded collection attached to each eager-loaded model.

Details

in ForwardsCalls at line 22
protected mixed forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in ForwardsCalls at line 52
protected mixed forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in ForwardsCalls at line 66
static protected never throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

Parameters

string $method

Return Value

never

Exceptions

BadMethodCallException

in Macroable at line 28
static void macro(string $name, callable|object $macro)

Register a custom macro.

Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 41
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 57
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 68
static void flushMacros()

Flush the existing macros.

Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 78
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 103
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 30
__construct(Builder $query, Model $parent, string $name, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string|null $relationName, bool $inverse, PermissionRegistrar $registrar, PermissionRelationContext $context)

Create a partition-aware morph-to-many relation.

Parameters

Builder $query
Model $parent
string $name
string $table
string $foreignPivotKey
string $relatedPivotKey
string $parentKey
string $relatedKey
string|null $relationName
bool $inverse
PermissionRegistrar $registrar
PermissionRelationContext $context

in Relation at line 105
static mixed noConstraints(Closure $callback)

Run a callback with constraints disabled on the relation.

Parameters

Closure $callback

Return Value

mixed

in Relation at line 124
static bool shouldAddConstraints()

Determine if constraints should be added to the relation query.

Return Value

bool

in BelongsToMany at line 177
void addConstraints()

Set the base constraints on the relation query.

Return Value

void

in MorphToMany at line 90
void addEagerConstraints(array $models)

Set the constraints for an eager load of the relation.

Parameters

array $models

Return Value

void

array initRelation(array $models, string $relation)

Initialize and mark eager-loaded relation collections.

Parameters

array $models
string $relation

Return Value

array

array match(array $models, Collection $results, string $relation)

Match and mark eager-loaded relation collections.

Parameters

array $models
Collection $results
string $relation

Return Value

array

Collection getResults()

Get and mark lazily loaded relation results.

Return Value

Collection

in Relation at line 170
Collection getEager()

Get the relationship for eager loading.

Return Value

Collection

in Relation at line 185
Model sole(array|string $columns = ['*'])

Execute the query and get the first result if it's the sole matching record.

Parameters

array|string $columns

Return Value

Model

Exceptions

TRelatedModel>
MultipleRecordsFoundException

in BelongsToMany at line 831
Collection get(array $columns = ['*'])

Execute the query as a "select" statement.

Parameters

array $columns

Return Value

Collection

in BelongsToMany at line 1156
void touch()

Touch all of the related models for the relationship.

E.g.: Touch all roles associated with this user.

Return Value

void

in Relation at line 230
int rawUpdate(array $attributes = [])

Run a raw update against the base query.

Parameters

array $attributes

Return Value

int

in Relation at line 242
Builder getRelationExistenceCountQuery(Builder $query, Builder $parentQuery)

Add the constraints for a relationship count query.

Parameters

Builder $query
Builder $parentQuery

Return Value

Builder

in MorphToMany at line 109
Builder getRelationExistenceQuery(Builder $query, Builder $parentQuery, mixed $columns = ['*'])

Add the constraints for an internal relationship existence query.

Essentially, these queries compare on column names like whereColumn.

Parameters

Builder $query
Builder $parentQuery
mixed $columns

Return Value

Builder

in Relation at line 272
string getRelationCountHash(bool $incrementJoinCount = true)

Get a relationship join table hash.

Parameters

bool $incrementJoinCount

Return Value

string

in Relation at line 283
protected array getKeys(array $models, string|null $key = null)

Get all of the primary keys for an array of models.

Parameters

array $models
string|null $key

Return Value

array

in Relation at line 295
protected Builder getRelationQuery()

Get the query builder that will contain the relationship constraints.

Return Value

Builder

in Relation at line 305
Builder getQuery()

Get the underlying query for the relation.

Return Value

Builder

in Relation at line 313
Builder getBaseQuery()

Get the base query builder driving the Eloquent builder.

Return Value

Builder

in Relation at line 321
Builder toBase()

Get a base query builder instance.

Return Value

Builder

in Relation at line 331
Model getParent()

Get the parent model of the relation.

Return Value

Model

in BelongsToMany at line 1437
string getQualifiedParentKeyName()

Get the fully qualified parent key name for the relation.

Return Value

string

in Relation at line 349
Model getRelated()

Get the related model of the relation.

Return Value

Model

in BelongsToMany at line 1381
string createdAt()

Get the name of the "created at" column.

Return Value

string

in BelongsToMany at line 1389
string updatedAt()

Get the name of the "updated at" column.

Return Value

string

in Relation at line 373
string relatedUpdatedAt()

Get the name of the related model's "updated at" column.

Return Value

string

in Relation at line 383
protected void whereInEager(string $whereIn, string $key, array $modelKeys, Builder|null $query = null)

Add a whereIn eager constraint for the given set of model keys to be loaded.

Parameters

string $whereIn
string $key
array $modelKeys
Builder|null $query

Return Value

void

in Relation at line 395
protected string whereInMethod(Model $model, string $key)

Get the name of the "where in" method for eager loading.

Parameters

Model $model
string $key

Return Value

string

in Relation at line 409
static void requireMorphMap(bool $requireMorphMap = true)

Prevent polymorphic relationships from being used without model mappings.

Boot-only. The flag persists in a static property for the worker lifetime and applies to every polymorphic resolution across all coroutines.

Parameters

bool $requireMorphMap

Return Value

void

in Relation at line 417
static bool requiresMorphMap()

Determine if polymorphic relationships require explicit model mapping.

Return Value

bool

in Relation at line 430
static array enforceMorphMap(array $map, bool $merge = true)

Define the morph map for polymorphic relations and require all morphed models to be explicitly mapped.

Boot-only. Sets both worker-wide morph state (requireMorphMap + morphMap) shared by every coroutine.

Parameters

array $map
bool $merge

Return Value

array

in Relation at line 447
static array morphMap(array|null $map = null, bool $merge = true)

Set or get the morph map for polymorphic relations.

Boot-only when setting. The map persists in a static property for the worker lifetime and applies to every polymorphic resolution across all coroutines.

Parameters

array|null $map
bool $merge

Return Value

array

in Relation at line 466
static protected array|null buildMorphMapFromModels(array|null $models = null)

Builds a table-keyed array from model class names.

Parameters

array|null $models

Return Value

array|null

in Relation at line 483
static string|null getMorphedModel(string $alias)

Get the model associated with a custom polymorphic type.

Parameters

string $alias

Return Value

string|null

in Relation at line 493
static int|string getMorphAlias(string $className)

Get the alias associated with a custom polymorphic class.

Parameters

string $className

Return Value

int|string

in Relation at line 501
static void flushState()

Flush all static state.

Return Value

void

in Relation at line 524
void __clone()

Force a clone of the underlying query builder when cloning.

Return Value

void

protected mixed getDictionaryKey(mixed $attribute)

Get a dictionary key attribute - casting it to a string if necessary.

Parameters

mixed $attribute

Return Value

mixed

Exceptions

InvalidArgumentException

array toggle(mixed $ids, bool $touch = true)

Toggles a model (or models) from the parent.

Each existing model is detached, and non existing ones are attached.

Parameters

mixed $ids
bool $touch

Return Value

array

array toggleOrFail(mixed $ids, bool $touch = true)

Toggle a model (or models) from the parent within a transaction.

Parameters

mixed $ids
bool $touch

Return Value

array

Exceptions

Throwable

array syncWithoutDetaching(Collection|Model|array|int|string|null $ids)

Sync the intermediate tables with a list of IDs without detaching.

Parameters

Collection|Model|array|int|string|null $ids

Return Value

array

array syncWithoutDetachingOrFail(Collection|Model|array|int|string|null $ids)

Sync the intermediate tables with a list of IDs without detaching within a transaction.

Parameters

Collection|Model|array|int|string|null $ids

Return Value

array

Exceptions

Throwable

array sync(Collection|Model|array|int|string|null $ids, bool $detaching = true)

Sync the intermediate tables with a list of IDs or collection of models.

Parameters

Collection|Model|array|int|string|null $ids
bool $detaching

Return Value

array

array syncOrFail(Collection|Model|array|int|string|null $ids, bool $detaching = true)

Sync the intermediate tables with a list of IDs or collection of models within a transaction.

Parameters

Collection|Model|array|int|string|null $ids
bool $detaching

Return Value

array

Exceptions

Throwable

array syncWithPivotValues(Collection|Model|array|int|string|null $ids, array $values, bool $detaching = true)

Sync the intermediate tables with a list of IDs or collection of models with the given pivot values.

Parameters

Collection|Model|array|int|string|null $ids
array $values
bool $detaching

Return Value

array

array syncWithPivotValuesOrFail(Collection|Model|array|int|string|null $ids, array $values, bool $detaching = true)

Sync the intermediate tables with a list of IDs or collection of models with the given pivot values within a transaction.

Parameters

Collection|Model|array|int|string|null $ids
array $values
bool $detaching

Return Value

array

Exceptions

Throwable

protected array formatRecordsList(array $records)

Format the sync / toggle record list so that it is keyed by ID.

Parameters

array $records

Return Value

array

protected array attachNew(array $records, array $current, bool $touch = true)

Attach all of the records that aren't in the given current records.

Parameters

array $records
array $current
bool $touch

Return Value

array

int updateExistingPivot(mixed $id, array $attributes, bool $touch = true)

Update an existing pivot record on the table.

Parameters

mixed $id
array $attributes
bool $touch

Return Value

int

int updateExistingPivotOrFail(mixed $id, array $attributes, bool $touch = true)

Update an existing pivot record on the table within a transaction.

Parameters

mixed $id
array $attributes
bool $touch

Return Value

int

Exceptions

Throwable

protected int updateExistingPivotUsingCustomClass(mixed $id, array $attributes, bool $touch)

Update an existing pivot record on the table via a custom class.

Parameters

mixed $id
array $attributes
bool $touch

Return Value

int

void attach(mixed $ids, array $attributes = [], bool $touch = true)

Attach a model to the parent.

Parameters

mixed $ids
array $attributes
bool $touch

Return Value

void

void attachOrFail(mixed $ids, array $attributes = [], bool $touch = true)

Attach a model to the parent within a transaction.

Parameters

mixed $ids
array $attributes
bool $touch

Return Value

void

Exceptions

Throwable

protected void attachUsingCustomClass(mixed $ids, array $attributes)

Attach a model to the parent using a custom class.

Parameters

mixed $ids
array $attributes

Return Value

void

protected array formatAttachRecords(array $ids, array $attributes)

Create an array of records to insert into the pivot table.

Parameters

array $ids
array $attributes

Return Value

array

protected array formatAttachRecord(int|string $key, mixed $value, array $attributes, bool $hasTimestamps)

Create a full attachment record payload.

Parameters

int|string $key
mixed $value
array $attributes
bool $hasTimestamps

Return Value

array

protected array extractAttachIdAndAttributes(mixed $key, mixed $value, array $attributes)

Get the attach record ID and extra attributes.

Parameters

mixed $key
mixed $value
array $attributes

Return Value

array

protected array baseAttachRecord(mixed $id, bool $timed)

Create a new pivot attachment record.

Parameters

mixed $id
bool $timed

Return Value

array

protected array addTimestampsToAttachment(array $record, bool $exists = false)

Set the creation and update timestamps on an attach record.

Parameters

array $record
bool $exists

Return Value

array

bool hasPivotColumn(string|null $column)

Determine whether the given column is defined as a pivot column.

Parameters

string|null $column

Return Value

bool

int detach(mixed $ids = null, bool $touch = true)

Detach models from the relationship.

Parameters

mixed $ids
bool $touch

Return Value

int

int detachOrFail(mixed $ids = null, bool $touch = true)

Detach models from the relationship within a transaction.

Parameters

mixed $ids
bool $touch

Return Value

int

Exceptions

Throwable

protected int detachUsingCustomClass(mixed $ids)

Detach models from the relationship using a custom class.

Parameters

mixed $ids

Return Value

int

protected Collection getCurrentlyAttachedPivots()

Get the pivot models that are currently attached.

Return Value

Collection

protected Collection getCurrentlyAttachedPivotsForIds(mixed $ids = null)

Get the pivot models that are currently attached, filtered by related model keys.

Parameters

mixed $ids

Return Value

Collection

Model newPivot(array $attributes = [], bool $exists = false)

Create a new pivot model instance.

Parameters

array $attributes
bool $exists

Return Value

Model

Model newExistingPivot(array $attributes = [])

Create a new existing pivot model instance.

Parameters

array $attributes

Return Value

Model

Builder newPivotStatement()

Get a new plain query builder for the pivot table.

Return Value

Builder

Builder newPivotStatementForId(mixed $id)

Get a new pivot statement for a given "other" ID.

Parameters

mixed $id

Return Value

Builder

Builder newPivotQuery()

Create a new query builder for the pivot table.

Return Value

Builder

InteractsWithPivotTable withPivot(mixed $columns)

Set the columns on the pivot table to retrieve.

Parameters

mixed $columns

Return Value

InteractsWithPivotTable

protected array parseIds(mixed $value)

Get all of the IDs from the given mixed value.

Parameters

mixed $value

Return Value

array

protected mixed parseId(mixed $value)

Get the ID from the given mixed value.

Parameters

mixed $value

Return Value

mixed

protected array castKeys(array $keys)

Cast the given keys to integers if they are numeric and string otherwise.

Parameters

array $keys

Return Value

array

protected mixed castKey(mixed $key)

Cast the given key to convert to primary key type.

Parameters

mixed $key

Return Value

mixed

protected array castAttributes(array $attributes)

Cast the given pivot attributes.

Parameters

array $attributes

Return Value

array

protected mixed getTypeSwapValue(string $type, mixed $value)

Converts a given value to a given type value.

Parameters

string $type
mixed $value

Return Value

mixed

in BelongsToMany at line 155
protected string resolveTableName(string $table)

Attempt to resolve the intermediate table name from the given string.

Parameters

string $table

Return Value

string

in BelongsToMany at line 192
protected BelongsToMany performJoin(Builder|null $query = null)

Set the join clause for the relation query.

Parameters

Builder|null $query

Return Value

BelongsToMany

in MorphToMany at line 81
protected BelongsToMany addWhereConstraints()

Set the where clause for the relation query.

Return Value

BelongsToMany

in BelongsToMany at line 272
protected array buildDictionary(Collection $results)

Build model dictionary keyed by the relation's foreign key.

Parameters

Collection $results

Return Value

array

in BelongsToMany at line 299
string getPivotClass()

Get the class being used for pivot models.

Return Value

string

in BelongsToMany at line 314
BelongsToMany using(string $class)

Specify the custom pivot model to use for the relationship.

Parameters

string $class

Return Value

BelongsToMany

in BelongsToMany at line 331
BelongsToMany as(string $accessor)

Specify the custom pivot accessor to use for the relationship.

Parameters

string $accessor

Return Value

BelongsToMany

in BelongsToMany at line 344
BelongsToMany wherePivot(mixed $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Set a where clause for a pivot table column.

Parameters

mixed $column
mixed $operator
mixed $value
string $boolean

Return Value

BelongsToMany

in BelongsToMany at line 357
BelongsToMany wherePivotBetween(mixed $column, array $values, string $boolean = 'and', bool $not = false)

Set a "where between" clause for a pivot table column.

Parameters

mixed $column
array $values
string $boolean
bool $not

Return Value

BelongsToMany

in BelongsToMany at line 368
BelongsToMany orWherePivotBetween(mixed $column, array $values)

Set a "or where between" clause for a pivot table column.

Parameters

mixed $column
array $values

Return Value

BelongsToMany

in BelongsToMany at line 379
BelongsToMany wherePivotNotBetween(mixed $column, array $values, string $boolean = 'and')

Set a "where pivot not between" clause for a pivot table column.

Parameters

mixed $column
array $values
string $boolean

Return Value

BelongsToMany

in BelongsToMany at line 390
BelongsToMany orWherePivotNotBetween(mixed $column, array $values)

Set a "or where not between" clause for a pivot table column.

Parameters

mixed $column
array $values

Return Value

BelongsToMany

in BelongsToMany at line 401
BelongsToMany wherePivotIn(mixed $column, mixed $values, string $boolean = 'and', bool $not = false)

Set a "where in" clause for a pivot table column.

Parameters

mixed $column
mixed $values
string $boolean
bool $not

Return Value

BelongsToMany

in BelongsToMany at line 414
BelongsToMany orWherePivot(mixed $column, mixed $operator = null, mixed $value = null)

Set an "or where" clause for a pivot table column.

Parameters

mixed $column
mixed $operator
mixed $value

Return Value

BelongsToMany

in BelongsToMany at line 429
BelongsToMany withPivotValue(mixed $column, mixed $value = null)

Set a where clause for a pivot table column.

In addition, new pivot records will receive this value.

Parameters

mixed $column
mixed $value

Return Value

BelongsToMany

Exceptions

InvalidArgumentException

in BelongsToMany at line 453
BelongsToMany orWherePivotIn(string $column, mixed $values)

Set an "or where in" clause for a pivot table column.

Parameters

string $column
mixed $values

Return Value

BelongsToMany

in BelongsToMany at line 464
BelongsToMany wherePivotNotIn(mixed $column, mixed $values, string $boolean = 'and')

Set a "where not in" clause for a pivot table column.

Parameters

mixed $column
mixed $values
string $boolean

Return Value

BelongsToMany

in BelongsToMany at line 474
BelongsToMany orWherePivotNotIn(string $column, mixed $values)

Set an "or where not in" clause for a pivot table column.

Parameters

string $column
mixed $values

Return Value

BelongsToMany

in BelongsToMany at line 485
BelongsToMany wherePivotNull(mixed $column, string $boolean = 'and', bool $not = false)

Set a "where null" clause for a pivot table column.

Parameters

mixed $column
string $boolean
bool $not

Return Value

BelongsToMany

in BelongsToMany at line 498
BelongsToMany wherePivotNotNull(mixed $column, string $boolean = 'and')

Set a "where not null" clause for a pivot table column.

Parameters

mixed $column
string $boolean

Return Value

BelongsToMany

in BelongsToMany at line 509
BelongsToMany orWherePivotNull(mixed $column, bool $not = false)

Set a "or where null" clause for a pivot table column.

Parameters

mixed $column
bool $not

Return Value

BelongsToMany

in BelongsToMany at line 520
BelongsToMany orWherePivotNotNull(mixed $column)

Set a "or where not null" clause for a pivot table column.

Parameters

mixed $column

Return Value

BelongsToMany

in BelongsToMany at line 532
BelongsToMany orderByPivot(mixed $column, SortDirection|string $direction = SortDirection::Ascending)

Add an "order by" clause for a pivot table column.

Parameters

mixed $column
SortDirection|string $direction

Return Value

BelongsToMany

in BelongsToMany at line 543
BelongsToMany orderByPivotDesc(mixed $column)

Add an "order by desc" clause for a pivot table column.

Parameters

mixed $column

Return Value

BelongsToMany

in BelongsToMany at line 557
Collection|Model findOrNew(mixed $id, array $columns = ['*'])

Find a related model by its primary key or return a new instance of the related model.

Parameters

mixed $id
array $columns

Return Value

Collection|Model

in BelongsToMany at line 571
Model firstOrNew(array $attributes = [], Closure|array $values = [])

Get the first related model record matching the attributes or instantiate it.

Parameters

array $attributes
Closure|array $values

Return Value

Model

in BelongsToMany at line 585
Model firstOrCreate(array $attributes = [], Closure|array $values = [], array $joining = [], bool $touch = true)

Get the first record matching the attributes. If the record is not found, create it.

Parameters

array $attributes
Closure|array $values
array $joining
bool $touch

Return Value

Model

in BelongsToMany at line 607
Model createOrFirst(array $attributes = [], Closure|array $values = [], array $joining = [], bool $touch = true)

Attempt to create the record. If a unique constraint violation occurs, attempt to find the matching record.

Parameters

array $attributes
Closure|array $values
array $joining
bool $touch

Return Value

Model

in BelongsToMany at line 629
Model updateOrCreate(array $attributes, Closure|array $values = [], array $joining = [], bool $touch = true)

Create or update a related record matching the attributes, and fill it with values.

Parameters

array $attributes
Closure|array $values
array $joining
bool $touch

Return Value

Model

in BelongsToMany at line 649
Collection|Model|null find(mixed $id, array $columns = ['*'])

Find a related model by its primary key.

Parameters

mixed $id
array $columns

Return Value

Collection|Model|null

in BelongsToMany at line 670
Model findSole(mixed $id, array $columns = ['*'])

Find a sole related model by its primary key.

Parameters

mixed $id
array $columns

Return Value

Model

Exceptions

TRelatedModel>
MultipleRecordsFoundException

in BelongsToMany at line 685
Collection findMany(Arrayable|array $ids, array $columns = ['*'])

Find multiple related models by their primary keys.

Parameters

Arrayable|array $ids
array $columns

Return Value

Collection

in BelongsToMany at line 709
Collection|Model findOrFail(mixed $id, array $columns = ['*'])

Find a related model by its primary key or throw an exception.

Parameters

mixed $id
array $columns

Return Value

Collection|Model

Exceptions

TRelatedModel>

in BelongsToMany at line 739
mixed findOr(mixed $id, Closure|array|string $columns = ['*'], Closure|null $callback = null)

Find a related model by its primary key or call a callback.

Parameters

mixed $id
Closure|array|string $columns
Closure|null $callback

Return Value

mixed

in BelongsToMany at line 767
Model|null firstWhere(Closure|string|array $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Add a basic where clause to the query, and return the first result.

Parameters

Closure|string|array $column
mixed $operator
mixed $value
string $boolean

Return Value

Model|null

in BelongsToMany at line 777
Model|null first(array $columns = ['*'])

Execute the query and get the first result.

Parameters

array $columns

Return Value

Model|null

in BelongsToMany at line 791
Model firstOrFail(array $columns = ['*'])

Execute the query and get the first result or throw an exception.

Parameters

array $columns

Return Value

Model

Exceptions

TRelatedModel>

in BelongsToMany at line 809
mixed firstOr(Closure|array $columns = ['*'], Closure|null $callback = null)

Execute the query and get the first result or call a callback.

Parameters

Closure|array $columns
Closure|null $callback

Return Value

mixed

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

Get the select columns for the relation query.

Parameters

array $columns

Return Value

array

in MorphToMany at line 168
protected array aliasedPivotColumns()

Get the pivot columns for the relation.

"pivot_" is prefixed at each column for easy removal later.

Return Value

array

in BelongsToMany at line 892
mixed paginate(int|null $perPage = null, array $columns = ['*'], string $pageName = 'page', int|null $page = null)

Get a paginator for the "select" statement.

Parameters

int|null $perPage
array $columns
string $pageName
int|null $page

Return Value

mixed

in BelongsToMany at line 906
mixed simplePaginate(int|null $perPage = null, array $columns = ['*'], string $pageName = 'page', int|null $page = null)

Paginate the given query into a simple paginator.

Parameters

int|null $perPage
array $columns
string $pageName
int|null $page

Return Value

mixed

in BelongsToMany at line 920
mixed cursorPaginate(int|null $perPage = null, array $columns = ['*'], string $cursorName = 'cursor', string|null $cursor = null)

Paginate the given query into a cursor paginator.

Parameters

int|null $perPage
array $columns
string $cursorName
string|null $cursor

Return Value

mixed

in BelongsToMany at line 932
bool chunk(int $count, callable $callback)

Chunk the results of the query.

Parameters

int $count
callable $callback

Return Value

bool

in BelongsToMany at line 944
bool chunkById(int $count, callable $callback, string|null $column = null, string|null $alias = null)

Chunk the results of a query by comparing numeric IDs.

Parameters

int $count
callable $callback
string|null $column
string|null $alias

Return Value

bool

in BelongsToMany at line 952
bool chunkByIdDesc(int $count, callable $callback, string|null $column = null, string|null $alias = null)

Chunk the results of a query by comparing IDs in descending order.

Parameters

int $count
callable $callback
string|null $column
string|null $alias

Return Value

bool

in BelongsToMany at line 960
bool eachById(callable $callback, int $count = 1000, string|null $column = null, string|null $alias = null)

Execute a callback over each item while chunking by ID.

Parameters

callable $callback
int $count
string|null $column
string|null $alias

Return Value

bool

in BelongsToMany at line 974
bool orderedChunkById(int $count, callable $callback, string|null $column = null, string|null $alias = null, SortDirection|bool $descending = false)

Chunk the results of a query by comparing IDs in a given order.

Parameters

int $count
callable $callback
string|null $column
string|null $alias
SortDirection|bool $descending

Return Value

bool

in BelongsToMany at line 992
bool each(callable $callback, int $count = 1000)

Execute a callback over each item while chunking.

Parameters

callable $callback
int $count

Return Value

bool

in BelongsToMany at line 1008
mixed lazy(int $chunkSize = 1000)

Query lazily, by chunks of the given size.

Parameters

int $chunkSize

Return Value

mixed

in BelongsToMany at line 1022
mixed lazyById(int $chunkSize = 1000, string|null $column = null, string|null $alias = null)

Query lazily, by chunking the results of a query by comparing IDs.

Parameters

int $chunkSize
string|null $column
string|null $alias

Return Value

mixed

in BelongsToMany at line 1042
mixed lazyByIdDesc(int $chunkSize = 1000, string|null $column = null, string|null $alias = null)

Query lazily, by chunking the results of a query by comparing IDs in descending order.

Parameters

int $chunkSize
string|null $column
string|null $alias

Return Value

mixed

in BelongsToMany at line 1062
mixed cursor()

Get a lazy collection for the given query.

Return Value

mixed

in BelongsToMany at line 1076
protected Builder prepareQueryBuilder()

Prepare the query builder for query execution.

Return Value

Builder

in BelongsToMany at line 1086
protected void hydratePivotRelation(array $models)

Hydrate the pivot table relationship on the models.

Parameters

array $models

Return Value

void

in BelongsToMany at line 1103
protected array migratePivotAttributes(Model $model)

Get the pivot attributes from a model.

Parameters

Model $model

Return Value

array

in BelongsToMany at line 1124
void touchIfTouching()

If we're touching the parent model, touch.

Return Value

void

in BelongsToMany at line 1138
protected bool touchingParent()

Determine if we should touch the parent on sync.

Return Value

bool

in BelongsToMany at line 1146
protected string guessInverseRelation()

Attempt to guess the name of the inverse of the relation.

Return Value

string

in BelongsToMany at line 1179
Collection allRelatedIds()

Get all of the IDs for the related models.

Return Value

Collection

in BelongsToMany at line 1190
Model save(Model $model, array $pivotAttributes = [], bool $touch = true)

Save a new model and attach it to the parent model.

Parameters

Model $model
array $pivotAttributes
bool $touch

Return Value

Model

in BelongsToMany at line 1205
Model saveQuietly(Model $model, array $pivotAttributes = [], bool $touch = true)

Save a new model without raising any events and attach it to the parent model.

Parameters

Model $model
array $pivotAttributes
bool $touch

Return Value

Model

in BelongsToMany at line 1220
iterable saveMany(iterable $models, array $pivotAttributes = [])

Save an array of new models and attach them to the parent model.

Parameters

iterable $models
array $pivotAttributes

Return Value

iterable

in BelongsToMany at line 1239
iterable saveManyQuietly(iterable $models, array $pivotAttributes = [])

Save an array of new models without raising any events and attach them to the parent model.

Parameters

iterable $models
array $pivotAttributes

Return Value

iterable

in BelongsToMany at line 1251
Model create(array $attributes = [], array $joining = [], bool $touch = true)

Create a new instance of the related model.

Parameters

array $attributes
array $joining
bool $touch

Return Value

Model

in BelongsToMany at line 1272
array createMany(iterable $records, array $joinings = [])

Create an array of new instances of the related models.

Parameters

iterable $records
array $joinings

Return Value

array

in BelongsToMany at line 1303
Builder getRelationExistenceQueryForSelfJoin(Builder $query, Builder $parentQuery, mixed $columns = ['*'])

Add the constraints for a relationship query on the same table.

Parameters

Builder $query
Builder $parentQuery
mixed $columns

Return Value

Builder

in BelongsToMany at line 1321
BelongsToMany take(int $value)

Alias to set the "limit" value of the query.

Parameters

int $value

Return Value

BelongsToMany

in BelongsToMany at line 1331
BelongsToMany limit(int $value)

Set the "limit" value of the query.

Parameters

int $value

Return Value

BelongsToMany

in BelongsToMany at line 1353
string getExistenceCompareKey()

Get the key for comparing against the parent key in "has" query.

Return Value

string

in BelongsToMany at line 1363
BelongsToMany withTimestamps(string|false|null $createdAt = null, string|false|null $updatedAt = null)

Specify that the pivot table has creation and update timestamps.

Parameters

string|false|null $createdAt
string|false|null $updatedAt

Return Value

BelongsToMany

in BelongsToMany at line 1397
string getForeignPivotKeyName()

Get the foreign key for the relation.

Return Value

string

in BelongsToMany at line 1405
string getQualifiedForeignPivotKeyName()

Get the fully qualified foreign key for the relation.

Return Value

string

in BelongsToMany at line 1413
string getRelatedPivotKeyName()

Get the "related key" for the relation.

Return Value

string

in BelongsToMany at line 1421
string getQualifiedRelatedPivotKeyName()

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

Return Value

string

in BelongsToMany at line 1429
string getParentKeyName()

Get the parent key for the relationship.

Return Value

string

in BelongsToMany at line 1445
string getRelatedKeyName()

Get the related key for the relationship.

Return Value

string

in BelongsToMany at line 1453
string getQualifiedRelatedKeyName()

Get the fully qualified related key name for the relation.

Return Value

string

in BelongsToMany at line 1461
string getTable()

Get the intermediate table for the relationship.

Return Value

string

in BelongsToMany at line 1469
string|null getRelationName()

Get the relationship name for the relationship.

Return Value

string|null

in BelongsToMany at line 1479
string getPivotAccessor()

Get the name of the pivot accessor for this relationship.

Return Value

string

in BelongsToMany at line 1487
array getPivotColumns()

Get the pivot columns for this relationship.

Return Value

array

in BelongsToMany at line 1498
mixed qualifyPivotColumn(mixed $column)

Qualify the given column name by the pivot table.

Parameters

mixed $column

Return Value

mixed

in MorphToMany at line 184
string getMorphType()

Get the foreign key "type" name.

Return Value

string

in MorphToMany at line 192
string getQualifiedMorphTypeName()

Get the fully qualified morph type for the relation.

Return Value

string

in MorphToMany at line 202
string getMorphClass()

Get the class name of the parent model.

Return Value

string

in MorphToMany at line 210
bool getInverse()

Get the indicator for a reverse relationship.

Return Value

bool

protected void initializePermissionPartitionRelation(PermissionRegistrar $registrar, PermissionRelationContext $context)

Initialize the permission partition relation state.

Parameters

PermissionRegistrar $registrar
PermissionRelationContext $context

Return Value

void

protected void ensurePivotMatchesPermissionPartition(array $attributes)

Reject conflicting caller-supplied partition attributes.

Parameters

array $attributes

Return Value

void

protected void markPermissionRelationCollections(array $models, string $relation)

Mark the loaded collection attached to each eager-loaded model.

Parameters

array $models
string $relation

Return Value

void