PartitionedBelongsToMany
class PartitionedBelongsToMany extends BelongsToMany
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 |
| 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 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 PermissionRegistrar | $permissionPartitionRegistrar | from EnforcesPermissionPartition | |
| protected PermissionRelationContext | $permissionRelationContext | 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 belongs-to-many relation.
Determine if constraints should be added to the relation query.
Set the constraints for an eager load of the relation.
Initialize and mark eager-loaded relation collections.
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.
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.
Builds 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 without detaching within a transaction.
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 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 a new pivot statement for a given "other" ID.
Create a new query builder for the pivot table.
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.
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.
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.
Add an "order by desc" 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.
Create or update a related record matching the attributes, and fill it with values.
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.
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.
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 given column name by the pivot table.
Initialize the permission partition relation state.
Reject conflicting caller-supplied partition attributes.
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.
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 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.
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.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
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.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 103
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 31
__construct(Builder $query, Model $parent, string $table, string $foreignPivotKey, string $relatedPivotKey, string $parentKey, string $relatedKey, string|null $relationName, PermissionRegistrar $registrar, PermissionRelationContext $context)
Create a partition-aware belongs-to-many relation.
in
Relation at line 105
static mixed
noConstraints(Closure $callback)
Run a callback with constraints disabled on the relation.
in
Relation at line 124
static bool
shouldAddConstraints()
Determine if constraints should be added to the relation query.
in
BelongsToMany at line 177
void
addConstraints()
Set the base constraints on the relation query.
in
BelongsToMany at line 225
void
addEagerConstraints(array $models)
Set the constraints for an eager load of the relation.
in
EnforcesPermissionPartition at line 97
array
initRelation(array $models, string $relation)
Initialize and mark eager-loaded relation collections.
in
EnforcesPermissionPartition at line 111
array
match(array $models, Collection $results, string $relation)
Match and mark eager-loaded relation collections.
in
EnforcesPermissionPartition at line 75
Collection
getResults()
Get and mark lazily loaded relation results.
in
Relation at line 170
Collection
getEager()
Get the relationship for eager loading.
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.
in
BelongsToMany at line 831
Collection
get(array $columns = ['*'])
Execute the query as a "select" statement.
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.
in
Relation at line 230
int
rawUpdate(array $attributes = [])
Run a raw update against the base query.
in
Relation at line 242
Builder
getRelationExistenceCountQuery(Builder $query, Builder $parentQuery)
Add the constraints for a relationship count query.
in
BelongsToMany at line 1285
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 272
string
getRelationCountHash(bool $incrementJoinCount = true)
Get a relationship join table hash.
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.
in
Relation at line 295
protected Builder
getRelationQuery()
Get the query builder that will contain the relationship constraints.
in
Relation at line 313
Builder
getBaseQuery()
Get the base query builder driving the Eloquent builder.
in
BelongsToMany at line 1437
string
getQualifiedParentKeyName()
Get the fully qualified parent key name for the relation.
in
BelongsToMany at line 1381
string
createdAt()
Get the name of the "created at" column.
in
BelongsToMany at line 1389
string
updatedAt()
Get the name of the "updated at" column.
in
Relation at line 373
string
relatedUpdatedAt()
Get the name of the related model's "updated at" column.
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.
in
Relation at line 395
protected string
whereInMethod(Model $model, string $key)
Get the name of the "where in" method for eager loading.
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.
in
Relation at line 417
static bool
requiresMorphMap()
Determine if polymorphic relationships require explicit model mapping.
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.
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.
in
Relation at line 466
static protected array|null
buildMorphMapFromModels(array|null $models = null)
Builds a table-keyed array from model class names.
in
Relation at line 483
static string|null
getMorphedModel(string $alias)
Get the model associated with a custom polymorphic type.
in
Relation at line 493
static int|string
getMorphAlias(string $className)
Get the alias associated with a custom polymorphic class.
in
Relation at line 501
static void
flushState()
Flush all static state.
in
Relation at line 524
void
__clone()
Force a clone of the underlying query builder when cloning.
in
InteractsWithDictionary at line 19
protected mixed
getDictionaryKey(mixed $attribute)
Get a dictionary key attribute - casting it to a string if necessary.
in
InteractsWithPivotTable at line 22
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 71
array
toggleOrFail(mixed $ids, bool $touch = true)
Toggle a model (or models) from the parent within a transaction.
in
InteractsWithPivotTable at line 81
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
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 103
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 162
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 172
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 186
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 194
protected array
formatRecordsList(array $records)
Format the sync / toggle record list so that it is keyed by ID.
in
InteractsWithPivotTable at line 212
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 241
int
updateExistingPivot(mixed $id, array $attributes, bool $touch = true)
Update an existing pivot record on the table.
in
InteractsWithPivotTable at line 267
int
updateExistingPivotOrFail(mixed $id, array $attributes, bool $touch = true)
Update an existing pivot record on the table within a transaction.
in
InteractsWithPivotTable at line 275
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 295
void
attach(mixed $ids, array $attributes = [], bool $touch = true)
Attach a model to the parent.
in
InteractsWithPivotTable at line 319
void
attachOrFail(mixed $ids, array $attributes = [], bool $touch = true)
Attach a model to the parent within a transaction.
in
InteractsWithPivotTable at line 327
protected void
attachUsingCustomClass(mixed $ids, array $attributes)
Attach a model to the parent using a custom class.
in
InteractsWithPivotTable at line 342
protected array
formatAttachRecords(array $ids, array $attributes)
Create an array of records to insert into the pivot table.
in
InteractsWithPivotTable at line 367
protected array
formatAttachRecord(int|string $key, mixed $value, array $attributes, bool $hasTimestamps)
Create a full attachment record payload.
in
InteractsWithPivotTable at line 380
protected array
extractAttachIdAndAttributes(mixed $key, mixed $value, array $attributes)
Get the attach record ID and extra attributes.
in
InteractsWithPivotTable at line 390
protected array
baseAttachRecord(mixed $id, bool $timed)
Create a new pivot attachment record.
in
InteractsWithPivotTable at line 413
protected array
addTimestampsToAttachment(array $record, bool $exists = false)
Set the creation and update timestamps on an attach record.
in
InteractsWithPivotTable at line 437
bool
hasPivotColumn(string|null $column)
Determine whether the given column is defined as a pivot column.
in
InteractsWithPivotTable at line 445
int
detach(mixed $ids = null, bool $touch = true)
Detach models from the relationship.
in
InteractsWithPivotTable at line 483
int
detachOrFail(mixed $ids = null, bool $touch = true)
Detach models from the relationship within a transaction.
in
InteractsWithPivotTable at line 491
protected int
detachUsingCustomClass(mixed $ids)
Detach models from the relationship using a custom class.
in
InteractsWithPivotTable at line 507
protected Collection
getCurrentlyAttachedPivots()
Get the pivot models that are currently attached.
in
InteractsWithPivotTable at line 515
protected Collection
getCurrentlyAttachedPivotsForIds(mixed $ids = null)
Get the pivot models that are currently attached, filtered by related model keys.
in
InteractsWithPivotTable at line 537
Model
newPivot(array $attributes = [], bool $exists = false)
Create a new pivot model instance.
in
InteractsWithPivotTable at line 557
Model
newExistingPivot(array $attributes = [])
Create a new existing pivot model instance.
in
InteractsWithPivotTable at line 565
Builder
newPivotStatement()
Get a new plain query builder for the pivot table.
in
InteractsWithPivotTable at line 573
Builder
newPivotStatementForId(mixed $id)
Get a new pivot statement for a given "other" ID.
in
InteractsWithPivotTable at line 581
Builder
newPivotQuery()
Create a new query builder for the pivot table.
in
InteractsWithPivotTable at line 605
InteractsWithPivotTable
withPivot(mixed $columns)
Set the columns on the pivot table to retrieve.
in
InteractsWithPivotTable at line 618
protected array
parseIds(mixed $value)
Get all of the IDs from the given mixed value.
in
InteractsWithPivotTable at line 640
protected mixed
parseId(mixed $value)
Get the ID from the given mixed value.
in
InteractsWithPivotTable at line 648
protected array
castKeys(array $keys)
Cast the given keys to integers if they are numeric and string otherwise.
in
InteractsWithPivotTable at line 658
protected mixed
castKey(mixed $key)
Cast the given key to convert to primary key type.
in
InteractsWithPivotTable at line 669
protected array
castAttributes(array $attributes)
Cast the given pivot attributes.
in
InteractsWithPivotTable at line 679
protected mixed
getTypeSwapValue(string $type, mixed $value)
Converts a given value to a given type value.
in
BelongsToMany at line 155
protected string
resolveTableName(string $table)
Attempt to resolve the intermediate table name from the given string.
in
BelongsToMany at line 192
protected BelongsToMany
performJoin(Builder|null $query = null)
Set the join clause for the relation query.
in
BelongsToMany at line 214
protected BelongsToMany
addWhereConstraints()
Set the where clause for the relation query.
in
BelongsToMany at line 272
protected array
buildDictionary(Collection $results)
Build model dictionary keyed by the relation's foreign key.
in
BelongsToMany at line 299
string
getPivotClass()
Get the class being used for pivot models.
in
BelongsToMany at line 314
BelongsToMany
using(string $class)
Specify the custom pivot model to use for the relationship.
in
BelongsToMany at line 331
BelongsToMany
as(string $accessor)
Specify the custom pivot accessor to use for the relationship.
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.
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.
in
BelongsToMany at line 368
BelongsToMany
orWherePivotBetween(mixed $column, array $values)
Set a "or where between" clause for a pivot table column.
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.
in
BelongsToMany at line 390
BelongsToMany
orWherePivotNotBetween(mixed $column, array $values)
Set a "or where not between" clause for a pivot table column.
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.
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.
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.
in
BelongsToMany at line 453
BelongsToMany
orWherePivotIn(string $column, mixed $values)
Set an "or where in" clause for a pivot table column.
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.
in
BelongsToMany at line 474
BelongsToMany
orWherePivotNotIn(string $column, mixed $values)
Set an "or where not in" clause for a pivot table column.
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.
in
BelongsToMany at line 498
BelongsToMany
wherePivotNotNull(mixed $column, string $boolean = 'and')
Set a "where not null" clause for a pivot table column.
in
BelongsToMany at line 509
BelongsToMany
orWherePivotNull(mixed $column, bool $not = false)
Set a "or where null" clause for a pivot table column.
in
BelongsToMany at line 520
BelongsToMany
orWherePivotNotNull(mixed $column)
Set a "or where not null" clause for a pivot table column.
in
BelongsToMany at line 532
BelongsToMany
orderByPivot(mixed $column, SortDirection|string $direction = SortDirection::Ascending)
Add an "order by" clause for a pivot table column.
in
BelongsToMany at line 543
BelongsToMany
orderByPivotDesc(mixed $column)
Add an "order by desc" clause for a pivot table column.
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.
in
BelongsToMany at line 571
Model
firstOrNew(array $attributes = [], Closure|array $values = [])
Get the first related model record matching the attributes or instantiate it.
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.
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.
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.
in
BelongsToMany at line 649
Collection|Model|null
find(mixed $id, array $columns = ['*'])
Find a related model by its primary key.
in
BelongsToMany at line 670
Model
findSole(mixed $id, array $columns = ['*'])
Find a sole related model by its primary key.
in
BelongsToMany at line 685
Collection
findMany(Arrayable|array $ids, array $columns = ['*'])
Find multiple related models by their primary keys.
in
BelongsToMany at line 709
Collection|Model
findOrFail(mixed $id, array $columns = ['*'])
Find a related model by its primary key or throw an exception.
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.
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.
in
BelongsToMany at line 777
Model|null
first(array $columns = ['*'])
Execute the query and get the first result.
in
BelongsToMany at line 791
Model
firstOrFail(array $columns = ['*'])
Execute the query and get the first result or throw an exception.
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.
in
BelongsToMany at line 861
protected array
shouldSelect(array $columns = ['*'])
Get the select columns for the relation query.
in
BelongsToMany at line 875
protected array
aliasedPivotColumns()
Get the pivot columns for the relation.
"pivot_" is prefixed at each column for easy removal later.
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.
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.
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.
in
BelongsToMany at line 932
bool
chunk(int $count, callable $callback)
Chunk the results of the query.
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.
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.
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.
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.
in
BelongsToMany at line 992
bool
each(callable $callback, int $count = 1000)
Execute a callback over each item while chunking.
in
BelongsToMany at line 1008
mixed
lazy(int $chunkSize = 1000)
Query lazily, by chunks of the given size.
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.
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.
in
BelongsToMany at line 1062
mixed
cursor()
Get a lazy collection for the given query.
in
BelongsToMany at line 1076
protected Builder
prepareQueryBuilder()
Prepare the query builder for query execution.
in
BelongsToMany at line 1086
protected void
hydratePivotRelation(array $models)
Hydrate the pivot table relationship on the models.
in
BelongsToMany at line 1103
protected array
migratePivotAttributes(Model $model)
Get the pivot attributes from a model.
in
BelongsToMany at line 1124
void
touchIfTouching()
If we're touching the parent model, touch.
in
BelongsToMany at line 1138
protected bool
touchingParent()
Determine if we should touch the parent on sync.
in
BelongsToMany at line 1146
protected string
guessInverseRelation()
Attempt to guess the name of the inverse of the relation.
in
BelongsToMany at line 1179
Collection
allRelatedIds()
Get all of the IDs for the related models.
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.
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.
in
BelongsToMany at line 1220
iterable
saveMany(iterable $models, array $pivotAttributes = [])
Save an array of new models and attach them to the parent model.
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.
in
BelongsToMany at line 1251
Model
create(array $attributes = [], array $joining = [], bool $touch = true)
Create a new instance of the related model.
in
BelongsToMany at line 1272
array
createMany(iterable $records, array $joinings = [])
Create an array of new instances of the related models.
in
BelongsToMany at line 1303
Builder
getRelationExistenceQueryForSelfJoin(Builder $query, Builder $parentQuery, mixed $columns = ['*'])
Add the constraints for a relationship query on the same table.
in
BelongsToMany at line 1321
BelongsToMany
take(int $value)
Alias to set the "limit" value of the query.
in
BelongsToMany at line 1331
BelongsToMany
limit(int $value)
Set the "limit" value of the query.
in
BelongsToMany at line 1353
string
getExistenceCompareKey()
Get the key for comparing against the parent key in "has" query.
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.
in
BelongsToMany at line 1397
string
getForeignPivotKeyName()
Get the foreign key for the relation.
in
BelongsToMany at line 1405
string
getQualifiedForeignPivotKeyName()
Get the fully qualified foreign key for the relation.
in
BelongsToMany at line 1413
string
getRelatedPivotKeyName()
Get the "related key" for the relation.
in
BelongsToMany at line 1421
string
getQualifiedRelatedPivotKeyName()
Get the fully qualified "related key" for the relation.
in
BelongsToMany at line 1429
string
getParentKeyName()
Get the parent key for the relationship.
in
BelongsToMany at line 1445
string
getRelatedKeyName()
Get the related key for the relationship.
in
BelongsToMany at line 1453
string
getQualifiedRelatedKeyName()
Get the fully qualified related key name for the relation.
in
BelongsToMany at line 1461
string
getTable()
Get the intermediate table for the relationship.
in
BelongsToMany at line 1469
string|null
getRelationName()
Get the relationship name for the relationship.
in
BelongsToMany at line 1479
string
getPivotAccessor()
Get the name of the pivot accessor for this relationship.
in
BelongsToMany at line 1487
array
getPivotColumns()
Get the pivot columns for this relationship.
in
BelongsToMany at line 1498
mixed
qualifyPivotColumn(mixed $column)
Qualify the given column name by the pivot table.
in
EnforcesPermissionPartition at line 23
protected void
initializePermissionPartitionRelation(PermissionRegistrar $registrar, PermissionRelationContext $context)
Initialize the permission partition relation state.
in
EnforcesPermissionPartition at line 122
protected void
ensurePivotMatchesPermissionPartition(array $attributes)
Reject conflicting caller-supplied partition attributes.
in
EnforcesPermissionPartition at line 141
protected void
markPermissionRelationCollections(array $models, string $relation)
Mark the loaded collection attached to each eager-loaded model.