PartitionedMorphToMany
class PartitionedMorphToMany extends MorphToMany
Traits
Constants
| protected CONSTRAINTS_CONTEXT_KEY |
The context key for storing whether constraints are enabled. |
| protected NESTED_CONSTRAINTS_CONTEXT_KEY |
The context key for enabling constraints on nested relation attributes. |
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 |
| protected TRelatedModel | $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 array<int|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|null | $declaringInverseRelationship | The name of the declaring model's relationship on the pivot. |
from SupportsPivotInverseRelations |
| protected string|null | $relatedInverseRelationship | The name of the related model's relationship on the pivot. |
from SupportsPivotInverseRelations |
| 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 string[] | $pivotColumns | The pivot table columns to retrieve. |
from BelongsToMany |
| protected list<array{string, array<int, mixed>}> | $pivotConstraints | The pivot table restrictions in their original order. |
from BelongsToMany |
| protected Expression|string, value: mixed}> | $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 class-string|string | $morphClass | The morph class 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 | |
| protected ConnectionInterface|null | $permissionPivotConnection | from EnforcesPermissionPartition |
Methods
Forward a method call to the given object.
Forward a method call to the given object, returning $this if the forwarded call returned itself.
Throw a bad method call exception for the given method.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Create a partition-aware morph-to-many relation.
Run a callback without constraints while preserving them for nested relation attributes.
Run a callback with the configured relation constraints.
Run a callback with constraints when resolving a nested relation attribute.
Determine if constraints should be added to the relation query.
Set the constraints for an eager load of the relation.
Initialize the relation on a set of models.
Match and mark eager-loaded relation collections.
Get and mark lazily loaded relation results.
Execute the query and get the first result if it's the sole matching record.
Execute the query as a "select" statement.
Update related keys, splitting unbounded queries at the statement binding limit.
Add the constraints for a relationship count query.
Add the constraints for an internal relationship existence query.
Get a relationship join table hash.
Get all of the primary keys for an array of models.
Get the query builder that will contain the relationship constraints.
Get the fully-qualified parent key name for the relation.
Add a whereIn eager constraint for the given set of model keys to be loaded.
Prevent polymorphic relationships from being used without model mappings.
Determine if polymorphic relationships require explicit model mapping.
Define the morph map for polymorphic relations and require all morphed models to be explicitly mapped.
Set or get the morph map for polymorphic relations.
Build a table-keyed array from model class names.
Get the model associated with a custom polymorphic type.
Get the alias associated with a custom polymorphic class.
Get a dictionary key attribute - casting it to a string if necessary.
Toggles a model (or models) from the parent.
Toggle a model (or models) from the parent within a transaction.
Sync the intermediate tables with a list of IDs without detaching.
Sync the intermediate tables with a list of IDs or collection of models.
Sync the intermediate tables with a list of IDs or collection of models within a transaction.
Sync the intermediate tables with a list of IDs without detaching within a transaction.
Sync the intermediate tables with a list of IDs or collection of models with the given pivot values.
Sync the intermediate tables with a list of IDs or collection of models with the given pivot values within a transaction.
Format the sync / toggle record list so that it is keyed by ID.
Attach all of the records that aren't in the given current records.
Update an existing pivot record on the table.
Update an existing pivot record on the table within a transaction.
Update an existing pivot record on the table via a custom class.
Attach a model to the parent.
Attach a model to the parent within a transaction.
Attach a model to the parent using a custom class.
Create an array of records to insert into the pivot table.
Create a full attachment record payload.
Get the attach record ID and extra attributes.
Create a new pivot attachment record.
Set the creation and update timestamps on an attach record.
Determine whether the given column is defined as a pivot column.
Detach models from the relationship.
Detach models from the relationship within a transaction.
Detach models from the relationship using a custom class.
Get the pivot models that are currently attached.
Get the pivot models that are currently attached, filtered by related model keys.
Create a new pivot model instance.
Create a new existing pivot model instance.
Get a new plain query builder for the pivot table.
Get the connection that owns the pivot table.
Get a new pivot statement for a given "other" ID.
Create a new query builder for the pivot table.
Determine whether the relation has pivot constraints.
Set the columns on the pivot table to retrieve.
Get all of the IDs from the given mixed value.
Cast the given keys to integers if they are numeric and string otherwise.
Cast the given key to convert to primary key type.
Cast the given pivot attributes.
Converts a given value to a given type value.
Instruct Eloquent to link the declaring and related models back to the pivot after the relationship query has run.
Remove the chaperone relationships for this query.
Resolve the inverse relation name on the pivot for a given model.
Attempt to guess the inverse relation name on the pivot for a given model.
Derive the inverse relationship name from a pivot key.
Apply chaperone relationships to a pivot model instance.
Attempt to resolve the intermediate table name from the given string.
Specify the custom pivot model to use for the relationship.
Specify the custom pivot accessor to use for the relationship.
Set a where clause for a pivot table column.
Apply and record a pivot restriction for subsequent pivot writes.
Set a "where between" clause for a pivot table column.
Set a "or where between" clause for a pivot table column.
Set a "where pivot not between" clause for a pivot table column.
Set a "or where not between" clause for a pivot table column.
Set a "where in" clause for a pivot table column.
Set an "or where" clause for a pivot table column.
Set a where clause for a pivot table column.
Set an "or where in" clause for a pivot table column.
Set a "where not in" clause for a pivot table column.
Set an "or where not in" clause for a pivot table column.
Set a "where null" clause for a pivot table column.
Set a "where not null" clause for a pivot table column.
Set a "or where null" clause for a pivot table column.
Set a "or where not null" clause for a pivot table column.
Add an "order by" clause for a pivot table column.
Find a related model by its primary key or return a new instance of the related model.
Get the first related model record matching the attributes or instantiate it.
Get the first record matching the attributes. If the record is not found, create it.
Attempt to create the record. If a unique constraint violation occurs, attempt to find the matching record.
Determine if the related model is attached through the current pivot constraints.
Get the first record matching the attributes, including trashed records, and restore it. If the record is not found, create it.
Attempt to create the record. If a unique constraint violation occurs, find the matching record, including trashed records, and restore it.
Create or update a related record matching the attributes, and fill it with values.
Create a related record matching the attributes, or increment the existing record.
Find a related model by its primary key.
Find a sole related model by its primary key.
Find multiple related models by their primary keys.
Find a related model by its primary key or throw an exception.
Find a related model by its primary key or call a callback.
Add a basic where clause to the query, and return the first result.
Execute the query and get the first result.
Execute the query and get the first result or throw an exception.
Execute the query and get the first result or call a callback.
Get the select columns for the relation query.
Get a paginator for the "select" statement.
Paginate the given query into a simple paginator.
Paginate the given query into a cursor paginator.
Chunk the results of a query by comparing numeric IDs.
Chunk the results of a query by comparing IDs in descending order.
Execute a callback over each item while chunking by ID.
Chunk the results of a query by comparing IDs in a given order.
Execute a callback over each item while chunking.
Run a map over each item while chunking.
Query lazily, by chunking the results of a query by comparing IDs.
Query lazily, by chunking the results of a query by comparing IDs in descending order.
Hydrate the pivot table relationship on the models.
Attempt to guess the name of the inverse of the relation.
Save a new model and attach it to the parent model.
Save a new model without raising any events and attach it to the parent model.
Save an array of new models and attach them to the parent model.
Save an array of new models without raising any events and attach them to the parent model.
Create a new instance of the related model.
Create an array of new instances of the related models.
Create a new instance of the related model without raising any events and attach it to the parent model.
Create an array of new instances of the related models without raising any events and attach them to the parent model.
Create a new instance of the related model and attach it to the parent model. Allow mass-assignment.
Create a new instance of the related model with mass assignment without raising any events and attach it to the parent model.
Add the constraints for a relationship query on the same table.
Get the key for comparing against the parent key in "has" query.
Specify that the pivot table has creation and update timestamps.
Get the fully-qualified foreign key for the relation.
Get the fully-qualified "related key" for the relation.
Get the fully-qualified related key name for the relation.
Get the name of the pivot accessor for this relationship.
Qualify the column names in the given query's where clauses by the pivot table.
Get the fully-qualified morph type for the relation.
Initialize the permission partition relation state.
Get the relation's captured permission context.
Reject conflicting caller-supplied partition attributes.
Details
in
ForwardsCalls at line 22
protected mixed
forwardCallTo(mixed $object, string $method, array $parameters)
Forward a method call to the given object.
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.
in
ForwardsCalls at line 66
static protected never
throwBadMethodCallException(string $method)
Throw a bad method call exception for the given method.
in
Macroable at line 30
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 44
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 61
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 72
static void
flushMacros()
Flush the existing macros.
Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 83
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 108
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
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.
in
Relation at line 112
static mixed
noConstraints(Closure $callback)
Run a callback with constraints disabled on the relation.
in
Relation at line 125
static mixed
noConstraintsForRelation(Closure $callback)
Run a callback without constraints while preserving them for nested relation attributes.
in
Relation at line 138
static protected mixed
withoutConstraints(Closure $callback, bool $constraintsForNestedRelations)
Run a callback with the configured relation constraints.
in
Relation at line 165
static mixed
withConstraints(Closure $callback)
Run a callback with constraints enabled on the relation.
in
Relation at line 186
static mixed
withConstraintsForNestedRelation(Closure $callback)
Run a callback with constraints when resolving a nested relation attribute.
in
Relation at line 196
static bool
shouldAddConstraints()
Determine if constraints should be added to the relation query.
in
BelongsToMany at line 184
void
addConstraints()
Set the base constraints on the relation query.
in
MorphToMany at line 90
void
addEagerConstraints(array $models)
Set the constraints for an eager load of the relation.
in
BelongsToMany at line 243
array
initRelation(array $models, string $relation)
Initialize the relation on a set of models.
in
EnforcesPermissionPartition at line 129
array
match(array $models, Collection $results, string $relation)
Match and mark eager-loaded relation collections.
in
EnforcesPermissionPartition at line 107
Collection
getResults()
Get and mark lazily loaded relation results.
in
Relation at line 242
Collection
getEager()
Get the relationship for eager loading.
in
Relation at line 257
Model
sole(array|string $columns = ['*'])
Execute the query and get the first result if it's the sole matching record.
in
BelongsToMany at line 1018
Collection
get(array $columns = ['*'])
Execute the query as a "select" statement.
in
BelongsToMany at line 1392
void
touch()
Touch all of the related models for the relationship.
E.g.: Touch all roles associated with this user.
in
Relation at line 305
protected void
updateRelatedKeys(Builder $query, string $column, Collection $keys, array $values)
Update related keys, splitting unbounded queries at the statement binding limit.
in
Relation at line 329
int
rawUpdate(array $attributes = [])
Run a raw update against the base query.
in
Relation at line 341
Builder
getRelationExistenceCountQuery(Builder $query, Builder $parentQuery)
Add the constraints for a relationship count query.
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.
in
Relation at line 371
string
getRelationCountHash(bool $incrementJoinCount = true)
Get a relationship join table hash.
in
Relation at line 382
protected array
getKeys(array $models, string|null $key = null)
Get all of the primary keys for an array of models.
in
Relation at line 394
protected Builder
getRelationQuery()
Get the query builder that will contain the relationship constraints.
in
Relation at line 412
Builder
getBaseQuery()
Get the base query builder driving the Eloquent builder.
in
BelongsToMany at line 1729
string
getQualifiedParentKeyName()
Get the fully-qualified parent key name for the relation.
in
Relation at line 456
Relation
withCasts(array $casts)
Apply query-time casts to the related model instance.
in
Relation at line 471
string
getRelatedClass()
Get the class name of the related model.
in
BelongsToMany at line 1673
string
createdAt()
Get the name of the "created at" column.
in
BelongsToMany at line 1681
string
updatedAt()
Get the name of the "updated at" column.
in
Relation at line 495
string
relatedUpdatedAt()
Get the name of the related model's "updated at" column.
in
Relation at line 505
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.
in
Relation at line 517
protected string
whereInMethod(Model $model, string $key)
Get the name of the "where in" method for eager loading.
in
Relation at line 531
static void
requireMorphMap(bool $requireMorphMap = true)
Prevent polymorphic relationships from being used without model mappings.
The flag persists in a static property for the worker lifetime and applies to every polymorphic resolution across all coroutines.
in
Relation at line 540
static bool
requiresMorphMap()
Determine if polymorphic relationships require explicit model mapping.
in
Relation at line 554
static array
enforceMorphMap(array $map, bool $merge = true)
Define the morph map for polymorphic relations and require all morphed models to be explicitly mapped.
Sets both worker-wide morph state (requireMorphMap + morphMap) shared by every coroutine.
in
Relation at line 571
static array
morphMap(array|null $map = null, bool $merge = true)
Set or get the morph map for polymorphic relations.
A given map persists in a static property for the worker lifetime and applies to every polymorphic resolution across all coroutines.
in
Relation at line 591
static protected array|null
buildMorphMapFromModels(array|null $models = null)
Build a table-keyed array from model class names.
in
Relation at line 607
static string|null
getMorphedModel(int|string|null $alias)
Get the model associated with a custom polymorphic type.
in
Relation at line 621
static int|string
getMorphAlias(string $className)
Get the alias associated with a custom polymorphic class.
in
Relation at line 639
static void
flushState()
Flush all static state.
in
Relation at line 662
void
__clone()
Force a clone of the underlying query builder when cloning.
in
InteractsWithDictionary at line 19
protected int|string|null
getDictionaryKey(mixed $attribute)
Get a dictionary key attribute - casting it to a string if necessary.
in
InteractsWithPivotTable at line 24
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.
in
InteractsWithPivotTable at line 73
array
toggleOrFail(mixed $ids, bool $touch = true)
Toggle a model (or models) from the parent within a transaction.
in
InteractsWithPivotTable at line 83
array
syncWithoutDetaching(Collection|Model|array|int|string|null $ids)
Sync the intermediate tables with a list of IDs without detaching.
in
InteractsWithPivotTable at line 93
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.
in
InteractsWithPivotTable at line 151
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.
in
InteractsWithPivotTable at line 163
array
syncWithoutDetachingOrFail(Collection|Model|array|int|string|null $ids)
Sync the intermediate tables with a list of IDs without detaching within a transaction.
in
InteractsWithPivotTable at line 173
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.
in
InteractsWithPivotTable at line 187
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.
in
InteractsWithPivotTable at line 195
protected array
formatRecordsList(array $records)
Format the sync / toggle record list so that it is keyed by ID.
in
InteractsWithPivotTable at line 211
protected array
attachNew(array $records, array $current, bool $touch = true)
Attach all of the records that aren't in the given current records.
in
InteractsWithPivotTable at line 240
int
updateExistingPivot(mixed $id, array $attributes, bool $touch = true)
Update an existing pivot record on the table.
in
InteractsWithPivotTable at line 266
int
updateExistingPivotOrFail(mixed $id, array $attributes, bool $touch = true)
Update an existing pivot record on the table within a transaction.
in
InteractsWithPivotTable at line 274
protected int
updateExistingPivotUsingCustomClass(mixed $id, array $attributes, bool $touch)
Update an existing pivot record on the table via a custom class.
in
InteractsWithPivotTable at line 294
void
attach(mixed $ids, array $attributes = [], bool $touch = true)
Attach a model to the parent.
in
InteractsWithPivotTable at line 318
void
attachOrFail(mixed $ids, array $attributes = [], bool $touch = true)
Attach a model to the parent within a transaction.
in
InteractsWithPivotTable at line 326
protected void
attachUsingCustomClass(mixed $ids, array $attributes)
Attach a model to the parent using a custom class.
in
InteractsWithPivotTable at line 341
protected array
formatAttachRecords(array $ids, array $attributes)
Create an array of records to insert into the pivot table.
in
InteractsWithPivotTable at line 366
protected array
formatAttachRecord(int|string $key, mixed $value, array $attributes, bool $hasTimestamps)
Create a full attachment record payload.
in
InteractsWithPivotTable at line 379
protected array
extractAttachIdAndAttributes(mixed $key, mixed $value, array $attributes)
Get the attach record ID and extra attributes.
in
InteractsWithPivotTable at line 389
protected array
baseAttachRecord(mixed $id, bool $timed)
Create a new pivot attachment record.
in
InteractsWithPivotTable at line 412
protected array
addTimestampsToAttachment(array $record, bool $exists = false)
Set the creation and update timestamps on an attach record.
in
InteractsWithPivotTable at line 436
bool
hasPivotColumn(string|null $column)
Determine whether the given column is defined as a pivot column.
in
InteractsWithPivotTable at line 444
int
detach(mixed $ids = null, bool $touch = true)
Detach models from the relationship.
in
InteractsWithPivotTable at line 482
int
detachOrFail(mixed $ids = null, bool $touch = true)
Detach models from the relationship within a transaction.
in
InteractsWithPivotTable at line 490
protected int
detachUsingCustomClass(mixed $ids)
Detach models from the relationship using a custom class.
in
InteractsWithPivotTable at line 499
protected Collection
getCurrentlyAttachedPivots()
Get the pivot models that are currently attached.
in
InteractsWithPivotTable at line 507
protected Collection
getCurrentlyAttachedPivotsForIds(mixed $ids = null)
Get the pivot models that are currently attached, filtered by related model keys.
in
InteractsWithPivotTable at line 521
Model
newPivot(array $attributes = [], bool $exists = false)
Create a new pivot model instance.
in
InteractsWithPivotTable at line 558
Model
newExistingPivot(array $attributes = [])
Create a new existing pivot model instance.
in
InteractsWithPivotTable at line 566
Builder
newPivotStatement()
Get a new plain query builder for the pivot table.
in
InteractsWithPivotTable at line 574
protected ConnectionInterface
getPivotConnection()
Get the connection that owns the pivot table.
in
InteractsWithPivotTable at line 582
Builder
newPivotStatementForId(mixed $id)
Get a new pivot statement for a given "other" ID.
in
InteractsWithPivotTable at line 590
Builder
newPivotQuery()
Create a new query builder for the pivot table.
in
InteractsWithPivotTable at line 608
protected bool
hasPivotConstraints()
Determine whether the relation has pivot constraints.
in
InteractsWithPivotTable at line 618
InteractsWithPivotTable
withPivot(mixed $columns)
Set the columns on the pivot table to retrieve.
in
InteractsWithPivotTable at line 631
protected array
parseIds(mixed $value)
Get all of the IDs from the given mixed value.
in
InteractsWithPivotTable at line 653
protected mixed
parseId(mixed $value)
Get the ID from the given mixed value.
in
InteractsWithPivotTable at line 661
protected array
castKeys(array $keys)
Cast the given keys to integers if they are numeric and string otherwise.
in
InteractsWithPivotTable at line 671
protected mixed
castKey(mixed $key)
Cast the given key to convert to primary key type.
in
InteractsWithPivotTable at line 682
protected array
castAttributes(array $attributes)
Cast the given pivot attributes.
in
InteractsWithPivotTable at line 692
protected mixed
getTypeSwapValue(string $type, mixed $value)
Converts a given value to a given type value.
in
SupportsPivotInverseRelations at line 29
SupportsPivotInverseRelations
chaperone(string|null $declaring = null, string|null $related = null)
Instruct Eloquent to link the declaring and related models back to the pivot after the relationship query has run.
in
SupportsPivotInverseRelations at line 74
SupportsPivotInverseRelations
withoutChaperone()
Remove the chaperone relationships for this query.
in
SupportsPivotInverseRelations at line 90
protected string|null
resolvePivotInverseRelation(Model $pivotModel, string|null $relation, string $foreignKey, Model $model)
Resolve the inverse relation name on the pivot for a given model.
If an explicit name is provided and invalid, an exception is thrown. If guessing fails, null is returned.
in
SupportsPivotInverseRelations at line 106
protected string|null
guessPivotInverseRelation(Model $pivotModel, string $foreignKey, Model $model)
Attempt to guess the inverse relation name on the pivot for a given model.
in
SupportsPivotInverseRelations at line 122
protected string
relationNameFromPivotKey(string $pivotKey, Model $model)
Derive the inverse relationship name from a pivot key.
in
SupportsPivotInverseRelations at line 130
protected void
applyChaperonesToPivot(Model $pivot, Model $declaring, Model $related)
Apply chaperone relationships to a pivot model instance.
in
BelongsToMany at line 162
protected string
resolveTableName(string $table)
Attempt to resolve the intermediate table name from the given string.
in
BelongsToMany at line 199
protected BelongsToMany
performJoin(Builder|null $query = null)
Set the join clause for the relation query.
in
MorphToMany at line 81
protected BelongsToMany
addWhereConstraints()
Set the where clause for the relation query.
in
BelongsToMany at line 291
protected array
buildDictionary(Collection $results)
Build model dictionary keyed by the relation's foreign key.
in
BelongsToMany at line 322
string
getPivotClass()
Get the class being used for pivot models.
in
BelongsToMany at line 337
BelongsToMany
using(string $class)
Specify the custom pivot model to use for the relationship.
in
BelongsToMany at line 354
BelongsToMany
as(string $accessor)
Specify the custom pivot accessor to use for the relationship.
in
BelongsToMany at line 367
BelongsToMany
wherePivot(Closure|Expression|string $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')
Set a where clause for a pivot table column.
in
BelongsToMany at line 394
protected BelongsToMany
addPivotConstraint(string $method, array $arguments)
Apply and record a pivot restriction for subsequent pivot writes.
in
BelongsToMany at line 418
protected BelongsToMany
addCompiledPivotConstraint(Builder $query)
Apply and record an already-built pivot predicate.
in
BelongsToMany at line 442
BelongsToMany
wherePivotBetween(Expression|string $column, array $values, string $boolean = 'and', bool $not = false)
Set a "where between" clause for a pivot table column.
in
BelongsToMany at line 452
BelongsToMany
orWherePivotBetween(Expression|string $column, array $values)
Set a "or where between" clause for a pivot table column.
in
BelongsToMany at line 462
BelongsToMany
wherePivotNotBetween(Expression|string $column, array $values, string $boolean = 'and')
Set a "where pivot not between" clause for a pivot table column.
in
BelongsToMany at line 472
BelongsToMany
orWherePivotNotBetween(Expression|string $column, array $values)
Set a "or where not between" clause for a pivot table column.
in
BelongsToMany at line 482
BelongsToMany
wherePivotIn(Expression|string $column, mixed $values, string $boolean = 'and', bool $not = false)
Set a "where in" clause for a pivot table column.
in
BelongsToMany at line 493
BelongsToMany
orWherePivot(Closure|Expression|string $column, mixed $operator = null, mixed $value = null)
Set an "or where" clause for a pivot table column.
in
BelongsToMany at line 508
BelongsToMany
withPivotValue(array|Expression|string $column, mixed $value = null)
Set a where clause for a pivot table column.
In addition, new pivot records will receive this value.
in
BelongsToMany at line 532
BelongsToMany
orWherePivotIn(Expression|string $column, mixed $values)
Set an "or where in" clause for a pivot table column.
in
BelongsToMany at line 542
BelongsToMany
wherePivotNotIn(Expression|string $column, mixed $values, string $boolean = 'and')
Set a "where not in" clause for a pivot table column.
in
BelongsToMany at line 552
BelongsToMany
orWherePivotNotIn(Expression|string $column, mixed $values)
Set an "or where not in" clause for a pivot table column.
in
BelongsToMany at line 562
BelongsToMany
wherePivotNull(Expression|string $column, string $boolean = 'and', bool $not = false)
Set a "where null" clause for a pivot table column.
in
BelongsToMany at line 572
BelongsToMany
wherePivotNotNull(Expression|string $column, string $boolean = 'and')
Set a "where not null" clause for a pivot table column.
in
BelongsToMany at line 582
BelongsToMany
orWherePivotNull(Expression|string $column, bool $not = false)
Set a "or where null" clause for a pivot table column.
in
BelongsToMany at line 592
BelongsToMany
orWherePivotNotNull(Expression|string $column)
Set a "or where not null" clause for a pivot table column.
in
BelongsToMany at line 603
BelongsToMany
orderByPivot(Expression|string $column, SortDirection|string $direction = SortDirection::Ascending)
Add an "order by" clause for a pivot table column.
in
BelongsToMany at line 613
BelongsToMany
orderByPivotDesc(Expression|string $column)
Add an "order by desc" clause for a pivot table column.
in
BelongsToMany at line 629
Collection|Model
findOrNew(mixed $id, array $columns = ['*'])
Find a related model by its primary key or return a new instance of the related model.
in
BelongsToMany at line 644
Model
firstOrNew(array $attributes = [], Closure|array $values = [])
Get the first related model record matching the attributes or instantiate it.
in
BelongsToMany at line 659
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.
in
BelongsToMany at line 688
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.
in
BelongsToMany at line 720
protected bool
hasAttachedPivot(Model $instance)
Determine if the related model is attached through the current pivot constraints.
in
BelongsToMany at line 733
Model
restoreOrCreate(array $attributes = [], Closure|array $values = [], array $joining = [], bool $touch = true)
Get the first record matching the attributes, including trashed records, and restore it. If the record is not found, create it.
in
BelongsToMany at line 750
Model
createOrRestore(array $attributes = [], Closure|array $values = [], array $joining = [], bool $touch = true)
Attempt to create the record. If a unique constraint violation occurs, find the matching record, including trashed records, and restore it.
in
BelongsToMany at line 765
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.
in
BelongsToMany at line 781
Model
incrementOrCreate(array $attributes, string $column = 'count', float|int $default = 1, float|int $step = 1, array $extra = [])
Create a related record matching the attributes, or increment the existing record.
in
BelongsToMany at line 801
Collection&Model&null
find(mixed $id, array $columns = ['*'])
Find a related model by its primary key.
in
BelongsToMany at line 822
Model
findSole(mixed $id, array $columns = ['*'])
Find a sole related model by its primary key.
in
BelongsToMany at line 837
Collection
findMany(Arrayable|array $ids, array $columns = ['*'])
Find multiple related models by their primary keys.
in
BelongsToMany at line 861
Collection&Model
findOrFail(mixed $id, array $columns = ['*'])
Find a related model by its primary key or throw an exception.
in
BelongsToMany at line 895
mixed
findOr(mixed $id, Closure|array|string $columns = ['*'], Closure|null $callback = null)
Find a related model by its primary key or call a callback.
in
BelongsToMany at line 923
protected mixed
parseFindIds(mixed $ids)
Normalize primary keys for related-model lookups.
in
BelongsToMany at line 944
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.
in
BelongsToMany at line 954
Model|null
first(array $columns = ['*'])
Execute the query and get the first result.
in
BelongsToMany at line 968
Model
firstOrFail(array $columns = ['*'])
Execute the query and get the first result or throw an exception.
in
BelongsToMany at line 986
mixed
firstOr(Closure|array $columns = ['*'], Closure|null $callback = null)
Execute the query and get the first result or call a callback.
in
BelongsToMany at line 1048
protected array
shouldSelect(array $columns = ['*'])
Get the select columns for the relation query.
in
MorphToMany at line 158
protected array
aliasedPivotColumns()
Get the pivot columns for the relation.
"pivot_" is prefixed at each column for easy removal later.
in
BelongsToMany at line 1080
mixed
paginate(int|null $perPage = null, array $columns = ['*'], string $pageName = 'page', int|null $page = null, Closure|int|null $total = null)
Get a paginator for the "select" statement.
in
BelongsToMany at line 1094
mixed
simplePaginate(int|null $perPage = null, array $columns = ['*'], string $pageName = 'page', int|null $page = null)
Paginate the given query into a simple paginator.
in
BelongsToMany at line 1108
mixed
cursorPaginate(int|null $perPage = null, array $columns = ['*'], string $cursorName = 'cursor', Cursor|string|null $cursor = null)
Paginate the given query into a cursor paginator.
in
BelongsToMany at line 1135
bool
chunk(int $count, callable $callback)
Chunk the results of the query.
in
BelongsToMany at line 1149
bool
chunkById(int $count, callable $callback, string|null $column = null, string|null $alias = null)
Chunk the results of a query by comparing numeric IDs.
in
BelongsToMany at line 1159
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.
in
BelongsToMany at line 1169
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.
in
BelongsToMany at line 1185
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.
in
BelongsToMany at line 1205
bool
each(callable $callback, int $count = 1000)
Execute a callback over each item while chunking.
in
BelongsToMany at line 1224
Collection
chunkMap(callable $callback, int $count = 1000)
Run a map over each item while chunking.
in
BelongsToMany at line 1242
mixed
lazy(int $chunkSize = 1000)
Query lazily, by chunks of the given size.
in
BelongsToMany at line 1256
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.
in
BelongsToMany at line 1276
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.
in
BelongsToMany at line 1296
mixed
cursor()
Get a lazy collection for the given query.
in
BelongsToMany at line 1310
protected Builder
prepareQueryBuilder()
Prepare the query builder for query execution.
in
BelongsToMany at line 1320
protected void
hydratePivotRelation(array $models)
Hydrate the pivot table relationship on the models.
in
BelongsToMany at line 1339
protected array
migratePivotAttributes(Model $model)
Get the pivot attributes from a model.
in
BelongsToMany at line 1360
void
touchIfTouching()
If we're touching the parent model, touch.
in
BelongsToMany at line 1374
protected bool
touchingParent()
Determine if we should touch the parent on sync.
in
BelongsToMany at line 1382
protected string
guessInverseRelation()
Attempt to guess the name of the inverse of the relation.
in
BelongsToMany at line 1423
Collection
allRelatedIds()
Get all of the IDs for the related models.
in
BelongsToMany at line 1434
Model
save(Model $model, array $pivotAttributes = [], bool $touch = true)
Save a new model and attach it to the parent model.
in
BelongsToMany at line 1449
Model
saveQuietly(Model $model, array $pivotAttributes = [], bool $touch = true)
Save a new model without raising any events and attach it to the parent model.
in
BelongsToMany at line 1464
iterable
saveMany(iterable $models, array $pivotAttributes = [])
Save an array of new models and attach them to the parent model.
in
BelongsToMany at line 1483
iterable
saveManyQuietly(iterable $models, array $pivotAttributes = [])
Save an array of new models without raising any events and attach them to the parent model.
in
BelongsToMany at line 1495
Model
create(array $attributes = [], array $joining = [], bool $touch = true)
Create a new instance of the related model.
in
BelongsToMany at line 1516
array
createMany(iterable $records, array $joinings = [])
Create an array of new instances of the related models.
in
BelongsToMany at line 1534
Model
createQuietly(array $attributes = [], array $joining = [], bool $touch = true)
Create a new instance of the related model without raising any events and attach it to the parent model.
in
BelongsToMany at line 1544
array
createManyQuietly(iterable $records, array $joinings = [])
Create an array of new instances of the related models without raising any events and attach them to the parent model.
in
BelongsToMany at line 1554
Model
forceCreate(array $attributes = [], array $joining = [], bool $touch = true)
Create a new instance of the related model and attach it to the parent model. Allow mass-assignment.
in
BelongsToMany at line 1572
Model
forceCreateQuietly(array $attributes = [], array $joining = [], bool $touch = true)
Create a new instance of the related model with mass assignment without raising any events and attach it to the parent model.
in
BelongsToMany at line 1595
Builder
getRelationExistenceQueryForSelfJoin(Builder $query, Builder $parentQuery, mixed $columns = ['*'])
Add the constraints for a relationship query on the same table.
in
BelongsToMany at line 1613
BelongsToMany
take(int $value)
Alias to set the "limit" value of the query.
in
BelongsToMany at line 1623
BelongsToMany
limit(int $value)
Set the "limit" value of the query.
in
BelongsToMany at line 1645
string
getExistenceCompareKey()
Get the key for comparing against the parent key in "has" query.
in
BelongsToMany at line 1655
BelongsToMany
withTimestamps(string|false|null $createdAt = null, string|false|null $updatedAt = null)
Specify that the pivot table has creation and update timestamps.
in
BelongsToMany at line 1689
string
getForeignPivotKeyName()
Get the foreign key for the relation.
in
BelongsToMany at line 1697
string
getQualifiedForeignPivotKeyName()
Get the fully-qualified foreign key for the relation.
in
BelongsToMany at line 1705
string
getRelatedPivotKeyName()
Get the "related key" for the relation.
in
BelongsToMany at line 1713
string
getQualifiedRelatedPivotKeyName()
Get the fully-qualified "related key" for the relation.
in
BelongsToMany at line 1721
string
getParentKeyName()
Get the parent key for the relationship.
in
BelongsToMany at line 1737
string
getRelatedKeyName()
Get the related key for the relationship.
in
BelongsToMany at line 1745
string
getQualifiedRelatedKeyName()
Get the fully-qualified related key name for the relation.
in
BelongsToMany at line 1753
string
getTable()
Get the intermediate table for the relationship.
in
BelongsToMany at line 1761
string|null
getRelationName()
Get the relationship name for the relationship.
in
BelongsToMany at line 1771
string
getPivotAccessor()
Get the name of the pivot accessor for this relationship.
in
BelongsToMany at line 1781
array
getPivotColumns()
Get the pivot columns for this relationship.
in
BelongsToMany at line 1789
protected void
qualifyPivotWheres(Builder $query)
Qualify the column names in the given query's where clauses by the pivot table.
in
BelongsToMany at line 1820
Expression|string
qualifyPivotColumn(Expression|string $column)
Qualify the given column name by the pivot table.
in
MorphToMany at line 174
string
getMorphType()
Get the foreign key "type" name.
in
MorphToMany at line 182
string
getQualifiedMorphTypeName()
Get the fully-qualified morph type for the relation.
in
MorphToMany at line 192
string
getMorphClass()
Get the class name of the parent model.
in
MorphToMany at line 200
bool
getInverse()
Get the indicator for a reverse relationship.
in
EnforcesPermissionPartition at line 26
protected void
initializePermissionPartitionRelation(PermissionRegistrar $registrar, PermissionRelationContext $context)
Initialize the permission partition relation state.
in
EnforcesPermissionPartition at line 37
PermissionRelationContext
getPermissionRelationContext()
Get the relation's captured permission context.
in
EnforcesPermissionPartition at line 149
protected void
ensurePivotMatchesPermissionPartition(array $attributes)
Reject conflicting caller-supplied partition attributes.