Methods |
public
|
__construct(
Builder $query,
Model $parent,
string $table,
string $foreignPivotKey,
string $relatedPivotKey,
string $parentKey,
string $relatedKey,
string|null $relationName = null,
): void
Create a new belongs to many relationship instance.
Create a new belongs to many relationship instance.
Overrides
Overriden by
|
#
|
public
|
addConstraints(): void
Set the base constraints on the relation query.
Set the base constraints on the relation query.
Implements
|
#
|
public
|
addEagerConstraints(array $models): void
Set the constraints for an eager load of the relation.
Set the constraints for an eager load of the relation.
Overriden by
Implements
|
#
|
public
|
initRelation(array $models, string $relation): array
Initialize the relation on a set of models.
Initialize the relation on a set of models.
Implements
|
#
|
public
|
match(array $models, Collection $results, string $relation): array
Match the eagerly loaded results to their parents.
Match the eagerly loaded results to their parents.
Implements
|
#
|
public
|
getPivotClass(): string
Get the class being used for pivot models.
Get the class being used for pivot models.
|
#
|
public
|
using(string $class): $this
Specify the custom pivot model to use for the relationship.
Specify the custom pivot model to use for the relationship.
|
#
|
public
|
as(string $accessor): $this
Specify the custom pivot accessor to use for the relationship.
Specify the custom pivot accessor to use for the relationship.
|
#
|
public
|
wherePivot(string $column, mixed $operator = null, mixed $value = null, string $boolean = 'and'): $this
Set a where clause for a pivot table column.
Set a where clause for a pivot table column.
|
#
|
public
|
wherePivotBetween(string $column, array $values, string $boolean = 'and', bool $not = false): $this
Set a "where between" clause for a pivot table column.
Set a "where between" clause for a pivot table column.
|
#
|
public
|
orWherePivotBetween(string $column, array $values): $this
Set a "or where between" clause for a pivot table column.
Set a "or where between" clause for a pivot table column.
|
#
|
public
|
wherePivotNotBetween(string $column, array $values, string $boolean = 'and'): $this
Set a "where pivot not between" clause for a pivot table column.
Set a "where pivot not between" clause for a pivot table column.
|
#
|
public
|
orWherePivotNotBetween(string $column, array $values): $this
Set a "or where not between" clause for a pivot table column.
Set a "or where not between" clause for a pivot table column.
|
#
|
public
|
wherePivotIn(string $column, mixed $values, string $boolean = 'and', bool $not = false): $this
Set a "where in" clause for a pivot table column.
Set a "where in" clause for a pivot table column.
|
#
|
public
|
orWherePivot(string $column, mixed $operator = null, mixed $value = null): $this
Set an "or where" clause for a pivot table column.
Set an "or where" clause for a pivot table column.
|
#
|
public
|
withPivotValue(string|array $column, mixed $value = null): $this
Set a where clause for a pivot table column.
Set a where clause for a pivot table column.
In addition, new pivot records will receive this value.
Throws
|
#
|
public
|
orWherePivotIn(string $column, mixed $values): $this
Set an "or where in" clause for a pivot table column.
Set an "or where in" clause for a pivot table column.
|
#
|
public
|
wherePivotNotIn(string $column, mixed $values, string $boolean = 'and'): $this
Set a "where not in" clause for a pivot table column.
Set a "where not in" clause for a pivot table column.
|
#
|
public
|
orWherePivotNotIn(string $column, mixed $values): $this
Set an "or where not in" clause for a pivot table column.
Set an "or where not in" clause for a pivot table column.
|
#
|
public
|
wherePivotNull(string $column, string $boolean = 'and', bool $not = false): $this
Set a "where null" clause for a pivot table column.
Set a "where null" clause for a pivot table column.
|
#
|
public
|
wherePivotNotNull(string $column, string $boolean = 'and'): $this
Set a "where not null" clause for a pivot table column.
Set a "where not null" clause for a pivot table column.
|
#
|
public
|
orWherePivotNull(string $column, bool $not = false): $this
Set a "or where null" clause for a pivot table column.
Set a "or where null" clause for a pivot table column.
|
#
|
public
|
orWherePivotNotNull(string $column): $this
Set a "or where not null" clause for a pivot table column.
Set a "or where not null" clause for a pivot table column.
|
#
|
public
|
orderByPivot(string $column, string $direction = 'asc'): $this
Add an "order by" clause for a pivot table column.
Add an "order by" clause for a pivot table column.
|
#
|
public
|
findOrNew(mixed $id, array $columns = ['*']): Collection|Model
Find a related model by its primary key or return a new instance of the related model.
Find a related model by its primary key or return a new instance of the related model.
|
#
|
public
|
firstOrNew(array $attributes): Model
Get the first related model record matching the attributes or instantiate it.
Get the first related model record matching the attributes or instantiate it.
|
#
|
public
|
firstOrCreate(array $attributes, array $joining = [], bool $touch = true): Model
Get the first related record matching the attributes or create it.
Get the first related record matching the attributes or create it.
|
#
|
public
|
updateOrCreate(array $attributes, array $values = [], array $joining = [], bool $touch = true): Model
Create or update a related record matching the attributes, and fill it with values.
Create or update a related record matching the attributes, and fill it with values.
|
#
|
public
|
find(mixed $id, array $columns = ['*']): Model|Collection|null
Find a related model by its primary key.
Find a related model by its primary key.
|
#
|
public
|
findMany(Arrayable|array $ids, array $columns = ['*']): Collection
Find multiple related models by their primary keys.
Find multiple related models by their primary keys.
|
#
|
public
|
findOrFail(mixed $id, array $columns = ['*']): Model|Collection
Find a related model by its primary key or throw an exception.
Find a related model by its primary key or throw an exception.
Throws
|
#
|
public
|
firstWhere(
Closure|string|array $column,
mixed $operator = null,
mixed $value = null,
string $boolean = 'and',
): Model|static
Add a basic where clause to the query, and return the first result.
Add a basic where clause to the query, and return the first result.
|
#
|
public
|
first(array $columns = ['*']): mixed
Execute the query and get the first result.
Execute the query and get the first result.
|
#
|
public
|
firstOrFail(array $columns = ['*']): Model|static
Execute the query and get the first result or throw an exception.
Execute the query and get the first result or throw an exception.
Throws
|
#
|
public
|
firstOr(Closure|array $columns = ['*'], Closure|null $callback = null): Model|static|mixed
Execute the query and get the first result or call a callback.
Execute the query and get the first result or call a callback.
|
#
|
public
|
getResults(): mixed
Get the results of the relationship.
Get the results of the relationship.
Implements
|
#
|
public
|
get(array $columns = ['*']): Collection
Execute the query as a "select" statement.
Execute the query as a "select" statement.
Overrides
|
#
|
public
|
paginate(
int|null $perPage = null,
array $columns = ['*'],
string $pageName = 'page',
int|null $page = null,
): LengthAwarePaginator
Get a paginator for the "select" statement.
Get a paginator for the "select" statement.
|
#
|
public
|
simplePaginate(
int|null $perPage = null,
array $columns = ['*'],
string $pageName = 'page',
int|null $page = null,
): Paginator
Paginate the given query into a simple paginator.
Paginate the given query into a simple paginator.
|
#
|
public
|
cursorPaginate(
int|null $perPage = null,
array $columns = ['*'],
string $cursorName = 'cursor',
string|null $cursor = null,
): CursorPaginator
Paginate the given query into a cursor paginator.
Paginate the given query into a cursor paginator.
|
#
|
public
|
chunk(int $count, callable $callback): bool
Chunk the results of the query.
Chunk the results of the query.
|
#
|
public
|
chunkById(int $count, callable $callback, string|null $column = null, string|null $alias = null): bool
Chunk the results of a query by comparing numeric IDs.
Chunk the results of a query by comparing numeric IDs.
|
#
|
public
|
each(callable $callback, int $count = 1000): bool
Execute a callback over each item while chunking.
Execute a callback over each item while chunking.
|
#
|
public
|
lazy(int $chunkSize = 1000): LazyCollection
Query lazily, by chunks of the given size.
Query lazily, by chunks of the given size.
|
#
|
public
|
lazyById(int $chunkSize = 1000, string|null $column = null, string|null $alias = null): LazyCollection
Query lazily, by chunking the results of a query by comparing IDs.
Query lazily, by chunking the results of a query by comparing IDs.
|
#
|
public
|
cursor(): LazyCollection
Get a lazy collection for the given query.
Get a lazy collection for the given query.
|
#
|
public
|
touchIfTouching(): void
If we're touching the parent model, touch.
If we're touching the parent model, touch.
|
#
|
public
|
touch(): void
Touch all of the related models for the relationship.
Touch all of the related models for the relationship.
E.g.: Touch all roles associated with this user.
Overrides
|
#
|
public
|
allRelatedIds(): Collection
Get all of the IDs for the related models.
Get all of the IDs for the related models.
|
#
|
public
|
save(Model $model, array $pivotAttributes = [], bool $touch = true): Model
Save a new model and attach it to the parent model.
Save a new model and attach it to the parent model.
|
#
|
public
|
saveMany(Collection|array $models, array $pivotAttributes = []): array
Save an array of new models and attach them to the parent model.
Save an array of new models and attach them to the parent model.
|
#
|
public
|
create(array $attributes = [], array $joining = [], bool $touch = true): Model
Create a new instance of the related model.
Create a new instance of the related model.
|
#
|
public
|
createMany(iterable $records, array $joinings = []): array
Create an array of new instances of the related models.
Create an array of new instances of the related models.
|
#
|
public
|
getRelationExistenceQuery(Builder $query, Builder $parentQuery, array|mixed $columns = ['*']): Builder
Add the constraints for a relationship query.
Add the constraints for a relationship query.
Overrides
Overriden by
|
#
|
public
|
getRelationExistenceQueryForSelfJoin(Builder $query, Builder $parentQuery, array|mixed $columns = ['*']): Builder
Add the constraints for a relationship query on the same table.
Add the constraints for a relationship query on the same table.
|
#
|
public
|
getExistenceCompareKey(): string
Get the key for comparing against the parent key in "has" query.
Get the key for comparing against the parent key in "has" query.
|
#
|
public
|
withTimestamps(mixed $createdAt = null, mixed $updatedAt = null): $this
Specify that the pivot table has creation and update timestamps.
Specify that the pivot table has creation and update timestamps.
|
#
|
public
|
createdAt(): string
Get the name of the "created at" column.
Get the name of the "created at" column.
Overrides
|
#
|
public
|
updatedAt(): string
Get the name of the "updated at" column.
Get the name of the "updated at" column.
Overrides
|
#
|
public
|
getForeignPivotKeyName(): string
Get the foreign key for the relation.
Get the foreign key for the relation.
|
#
|
public
|
getQualifiedForeignPivotKeyName(): string
Get the fully qualified foreign key for the relation.
Get the fully qualified foreign key for the relation.
|
#
|
public
|
getRelatedPivotKeyName(): string
Get the "related key" for the relation.
Get the "related key" for the relation.
|
#
|
public
|
getQualifiedRelatedPivotKeyName(): string
Get the fully qualified "related key" for the relation.
Get the fully qualified "related key" for the relation.
|
#
|
public
|
getParentKeyName(): string
Get the parent key for the relationship.
Get the parent key for the relationship.
|
#
|
public
|
getQualifiedParentKeyName(): string
Get the fully qualified parent key name for the relation.
Get the fully qualified parent key name for the relation.
Overrides
|
#
|
public
|
getRelatedKeyName(): string
Get the related key for the relationship.
Get the related key for the relationship.
|
#
|
public
|
getQualifiedRelatedKeyName(): string
Get the fully qualified related key name for the relation.
Get the fully qualified related key name for the relation.
|
#
|
public
|
getTable(): string
Get the intermediate table for the relationship.
Get the intermediate table for the relationship.
|
#
|
public
|
getRelationName(): string
Get the relationship name for the relationship.
Get the relationship name for the relationship.
|
#
|
public
|
getPivotAccessor(): string
Get the name of the pivot accessor for this relationship.
Get the name of the pivot accessor for this relationship.
|
#
|
public
|
getPivotColumns(): array
Get the pivot columns for this relationship.
Get the pivot columns for this relationship.
|
#
|
public
|
qualifyPivotColumn(string $column): string
Qualify the given column name by the pivot table.
Qualify the given column name by the pivot table.
|
#
|