Builder
class Builder implements Builder mixin Builder (View source)
Traits
Properties
protected Builder | $query | The base query builder instance. |
|
protected Model | $model | The model being queried. |
|
protected array | $eagerLoad | The relationships that should be eager loaded. |
|
static protected array | $macros | All of the globally registered builder macros. |
|
protected array | $localMacros | All of the locally registered builder macros. |
|
protected Closure | $onDelete | A replacement for the typical delete function. |
|
protected string[] | $propertyPassthru | The properties that should be returned from query builder. |
|
protected string[] | $passthru | The methods that should be returned from query builder. |
|
protected array | $scopes | Applied global scopes. |
|
protected array | $removedScopes | Removed global scopes. |
|
HigherOrderBuilderProxy read-only | $orWhere | ||
HigherOrderBuilderProxy read-only | $whereNot | ||
HigherOrderBuilderProxy read-only | $orWhereNot |
Methods
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Run a map over each item while chunking.
Execute a callback over each item while chunking.
Chunk the results of a query by comparing IDs.
Chunk the results of a query by comparing IDs in descending order.
Chunk the results of a query by comparing IDs in a given order.
Execute a callback over each item while chunking by ID.
Query lazily, by chunks of the given size.
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.
Query lazily, by chunking the results of a query by comparing IDs in a given order.
Execute the query and get the first result.
Execute the query and get the first result if it's the sole matching record.
Paginate the given query using a cursor paginator.
Get the original column name of the given column, without any aliasing.
Create a new length-aware paginator instance.
Create a new simple paginator instance.
Create a new cursor paginator instance.
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.
Add a relationship count / exists condition to the query.
Add nested relationship count / exists conditions to the query.
Add a relationship count / exists condition to the query with an "or".
Add a relationship count / exists condition to the query.
Add a relationship count / exists condition to the query with an "or".
Add a relationship count / exists condition to the query with where clauses.
Add a relationship count / exists condition to the query with where clauses.
Add a relationship count / exists condition to the query with where clauses and an "or".
Add a relationship count / exists condition to the query with where clauses.
Add a relationship count / exists condition to the query with where clauses and an "or".
Add a polymorphic relationship count / exists condition to the query.
Get the BelongsTo relationship for a single polymorphic type.
Add a polymorphic relationship count / exists condition to the query with an "or".
Add a polymorphic relationship count / exists condition to the query.
Add a polymorphic relationship count / exists condition to the query with an "or".
Add a polymorphic relationship count / exists condition to the query with where clauses.
Add a polymorphic relationship count / exists condition to the query with where clauses and an "or".
Add a polymorphic relationship count / exists condition to the query with where clauses.
Add a polymorphic relationship count / exists condition to the query with where clauses and an "or".
Add a basic where clause to a relationship query.
Add an "or where" clause to a relationship query.
Add a polymorphic relationship condition to the query with a where clause.
Add a polymorphic relationship condition to the query with an "or where" clause.
Add a morph-to relationship condition to the query.
Add a not morph-to relationship condition to the query.
Add a morph-to relationship condition to the query with an "or where" clause.
Add a not morph-to relationship condition to the query with an "or where" clause.
Add a "belongs to" relationship where clause to the query.
Add an "BelongsTo" relationship with an "or where" clause to the query.
Add subselect queries to include an aggregate value for a relationship.
Get the relation hashed column name for the given column and relation.
Add subselect queries to count the relations.
Add subselect queries to include the max of the relation's column.
Add subselect queries to include the min of the relation's column.
Add subselect queries to include the sum of the relation's column.
Add subselect queries to include the average of the relation's column.
Add subselect queries to include the existence of related models.
Add the "has" condition where clause to the query.
Merge the where constraints from another query to the current query.
Updates the table name for any columns with a new qualified name.
Add a sub-query count clause to this query.
Get the "has relation" base query instance.
Check if we can run an "exists" query to optimize performance.
Remove all or passed registered global scopes.
Get an array of global scopes that were removed from the query.
Add a where clause on the primary key to the query.
Add a where clause on the primary key to the query.
Add a basic where clause to the query.
Add a basic where clause to the query, and return the first result.
Add an "or where" clause to the query.
Add a basic "where not" clause to the query.
Add an "or where not" clause to the query.
Create a collection of models from plain arrays.
Create a collection of models from a raw query.
Find a model by its primary key.
Find a model by its primary key or throw an exception.
Find a model by its primary key or return fresh model instance.
Get the first 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 record matching the attributes, and fill it with values.
Execute the query and get the first result or throw an exception.
Get a single column's value from the first result of a query if it's the sole matching record.
Get a single column's value from the first result of the query or throw an exception.
Execute the query as a "select" statement.
Get the hydrated models without eager loading.
Eager load the relationships for the models.
Eagerly load the relationship on a set of models.
Get the relation instance for the given relation name.
Get the deeply nested relations for a given top-level relation.
Determine if the relationship is nested.
Get a lazy collection for the given query.
Add a generic "order by" clause if the query doesn't already have one.
Get a collection with the values of a given column.
Paginate the given query into a simple paginator.
Paginate the given query into a cursor paginator.
Ensure the proper order by required for cursor pagination.
Save a new model and return the instance. Allow mass-assignment.
Save a new model instance with mass assignment without raising model events.
Update records in the database.
Insert new records or update the existing ones.
Update the column's update timestamp.
Increment a column's value by a given amount.
Decrement a column's value by a given amount.
Add the "updated at" column to an array of values.
Add unique IDs to the inserted values.
Add timestamps to the inserted values.
Add the "updated at" column to the updated columns.
Delete records from the database.
Run the default delete function on the builder.
Determine if the given model has a scope.
Apply the scopes to the Eloquent builder instance and return it.
Apply the given scope on the current builder instance.
Apply the given named scope on the current builder instance.
Nest where conditions by slicing them at the given where count.
Slice where conditions at the given offset and add them to the query as a nested condition.
Create a where array with nested where conditions.
Prevent the specified relations from being eager loaded.
Set the relationships that should be eager loaded while removing any previously added eager loading specifications.
Create a new instance of the model being queried.
Parse a list of relations into individuals.
Prepare nested with relationships.
Combine an array of constraints into a single constraint.
Parse the attribute select constraints from the name.
Create a constraint to select the given columns for the relation.
Parse the nested relationships in a relation.
Apply query-time casts to the model instance.
Get the Eloquent builder instances that are used in the union of the query.
Get the relationships being eagerly loaded.
Set the relationships being eagerly loaded.
Indicate that the given relationships should not be eagerly loaded.
Flush the relationships being eagerly loaded.
Get the default key name of the table.
Checks if a macro is registered.
Get the given global macro by name.
Checks if a global macro is registered.
Dynamically access builder proxies.
Dynamically handle calls into the query instance.
Dynamically handle calls into the query instance.
Register the given mixin with the builder.
Force a clone of the underlying query builder when cloning.
Details
$this|TWhenReturnType
when($value = null, callable $callback = null, callable $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
$this|TUnlessReturnType
unless($value = null, callable $callback = null, callable $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
bool
chunk(int $count, callable $callback)
Chunk the results of the query.
Collection
chunkMap(callable $callback, int $count = 1000)
Run a map over each item while chunking.
bool
each(callable $callback, int $count = 1000)
Execute a callback over each item while chunking.
bool
chunkById(int $count, callable $callback, string|null $column = null, string|null $alias = null)
Chunk the results of a query by comparing IDs.
bool
chunkByIdDesc(int $count, callable $callback, string|null $column = null, string|null $alias = null)
Chunk the results of a query by comparing IDs in descending order.
bool
orderedChunkById(int $count, callable $callback, string|null $column = null, string|null $alias = null, bool $descending = false)
Chunk the results of a query by comparing IDs in a given order.
bool
eachById(callable $callback, int $count = 1000, string|null $column = null, string|null $alias = null)
Execute a callback over each item while chunking by ID.
LazyCollection
lazy(int $chunkSize = 1000)
Query lazily, by chunks of the given size.
LazyCollection
lazyById(int $chunkSize = 1000, string|null $column = null, string|null $alias = null)
Query lazily, by chunking the results of a query by comparing IDs.
LazyCollection
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.
protected LazyCollection
orderedLazyById(int $chunkSize = 1000, string|null $column = null, string|null $alias = null, bool $descending = false)
Query lazily, by chunking the results of a query by comparing IDs in a given order.
Model|object|BuildsQueries|null
first(array|string $columns = ['*'])
Execute the query and get the first result.
Model
sole(array|string $columns = ['*'])
Execute the query and get the first result if it's the sole matching record.
protected CursorPaginator
paginateUsingCursor(int $perPage, array|string $columns = ['*'], string $cursorName = 'cursor', Cursor|string|null $cursor = null)
Paginate the given query using a cursor paginator.
protected string
getOriginalColumnNameForCursorPagination(Builder|Builder $builder, string $parameter)
Get the original column name of the given column, without any aliasing.
protected LengthAwarePaginator
paginator(Collection $items, int $total, int $perPage, int $currentPage, array $options)
Create a new length-aware paginator instance.
protected Paginator
simplePaginator(Collection $items, int $perPage, int $currentPage, array $options)
Create a new simple paginator instance.
protected CursorPaginator
cursorPaginator(Collection $items, int $perPage, Cursor $cursor, array $options)
Create a new cursor paginator instance.
$this
tap(callable $callback)
Pass the query to a given callback.
protected mixed
forwardCallTo(mixed $object, string $method, array $parameters)
Forward a method call to the given object.
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.
static protected void
throwBadMethodCallException(string $method)
Throw a bad method call exception for the given method.
Builder|QueriesRelationships
has(Relation|string $relation, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure $callback = null)
Add a relationship count / exists condition to the query.
protected Builder|QueriesRelationships
hasNested(string $relations, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure|null $callback = null)
Add nested relationship count / exists conditions to the query.
Sets up recursive call to whereHas until we finish the nested relation.
Builder|QueriesRelationships
orHas(string $relation, string $operator = '>=', int $count = 1)
Add a relationship count / exists condition to the query with an "or".
Builder|QueriesRelationships
doesntHave(string $relation, string $boolean = 'and', Closure $callback = null)
Add a relationship count / exists condition to the query.
Builder|QueriesRelationships
orDoesntHave(string $relation)
Add a relationship count / exists condition to the query with an "or".
Builder|QueriesRelationships
whereHas(string $relation, Closure $callback = null, string $operator = '>=', int $count = 1)
Add a relationship count / exists condition to the query with where clauses.
Builder|QueriesRelationships
withWhereHas(string $relation, Closure $callback = null, string $operator = '>=', int $count = 1)
Add a relationship count / exists condition to the query with where clauses.
Also load the relationship with same condition.
Builder|QueriesRelationships
orWhereHas(string $relation, Closure $callback = null, string $operator = '>=', int $count = 1)
Add a relationship count / exists condition to the query with where clauses and an "or".
Builder|QueriesRelationships
whereDoesntHave(string $relation, Closure $callback = null)
Add a relationship count / exists condition to the query with where clauses.
Builder|QueriesRelationships
orWhereDoesntHave(string $relation, Closure $callback = null)
Add a relationship count / exists condition to the query with where clauses and an "or".
Builder|QueriesRelationships
hasMorph(MorphTo|string $relation, string|array $types, string $operator = '>=', int $count = 1, string $boolean = 'and', Closure $callback = null)
Add a polymorphic relationship count / exists condition to the query.
protected BelongsTo
getBelongsToRelation(MorphTo $relation, string $type)
Get the BelongsTo relationship for a single polymorphic type.
Builder|QueriesRelationships
orHasMorph(MorphTo|string $relation, string|array $types, string $operator = '>=', int $count = 1)
Add a polymorphic relationship count / exists condition to the query with an "or".
Builder|QueriesRelationships
doesntHaveMorph(MorphTo|string $relation, string|array $types, string $boolean = 'and', Closure $callback = null)
Add a polymorphic relationship count / exists condition to the query.
Builder|QueriesRelationships
orDoesntHaveMorph(MorphTo|string $relation, string|array $types)
Add a polymorphic relationship count / exists condition to the query with an "or".
Builder|QueriesRelationships
whereHasMorph(MorphTo|string $relation, string|array $types, Closure $callback = null, string $operator = '>=', int $count = 1)
Add a polymorphic relationship count / exists condition to the query with where clauses.
Builder|QueriesRelationships
orWhereHasMorph(MorphTo|string $relation, string|array $types, Closure $callback = null, string $operator = '>=', int $count = 1)
Add a polymorphic relationship count / exists condition to the query with where clauses and an "or".
Builder|QueriesRelationships
whereDoesntHaveMorph(MorphTo|string $relation, string|array $types, Closure $callback = null)
Add a polymorphic relationship count / exists condition to the query with where clauses.
Builder|QueriesRelationships
orWhereDoesntHaveMorph(MorphTo|string $relation, string|array $types, Closure $callback = null)
Add a polymorphic relationship count / exists condition to the query with where clauses and an "or".
Builder|QueriesRelationships
whereRelation(string $relation, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)
Add a basic where clause to a relationship query.
Builder|QueriesRelationships
orWhereRelation(string $relation, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)
Add an "or where" clause to a relationship query.
Builder|QueriesRelationships
whereMorphRelation(MorphTo|string $relation, string|array $types, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)
Add a polymorphic relationship condition to the query with a where clause.
Builder|QueriesRelationships
orWhereMorphRelation(MorphTo|string $relation, string|array $types, Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null)
Add a polymorphic relationship condition to the query with an "or where" clause.
Builder|QueriesRelationships
whereMorphedTo(MorphTo|string $relation, Model|string|null $model, $boolean = 'and')
Add a morph-to relationship condition to the query.
Builder|QueriesRelationships
whereNotMorphedTo(MorphTo|string $relation, Model|string $model, $boolean = 'and')
Add a not morph-to relationship condition to the query.
Builder|QueriesRelationships
orWhereMorphedTo(MorphTo|string $relation, Model|string|null $model)
Add a morph-to relationship condition to the query with an "or where" clause.
Builder|QueriesRelationships
orWhereNotMorphedTo(MorphTo|string $relation, Model|string $model)
Add a not morph-to relationship condition to the query with an "or where" clause.
$this
whereBelongsTo(Model|Model> $related, string|null $relationshipName = null, string $boolean = 'and')
Add a "belongs to" relationship where clause to the query.
$this
orWhereBelongsTo(Model $related, string|null $relationshipName = null)
Add an "BelongsTo" relationship with an "or where" clause to the query.
$this
withAggregate(mixed $relations, Expression|string $column, string $function = null)
Add subselect queries to include an aggregate value for a relationship.
protected string
getRelationHashedColumn(string $column, Relation $relation)
Get the relation hashed column name for the given column and relation.
$this
withCount(mixed $relations)
Add subselect queries to count the relations.
$this
withMax(string|array $relation, Expression|string $column)
Add subselect queries to include the max of the relation's column.
$this
withMin(string|array $relation, Expression|string $column)
Add subselect queries to include the min of the relation's column.
$this
withSum(string|array $relation, Expression|string $column)
Add subselect queries to include the sum of the relation's column.
$this
withAvg(string|array $relation, Expression|string $column)
Add subselect queries to include the average of the relation's column.
$this
withExists(string|array $relation)
Add subselect queries to include the existence of related models.
protected Builder|QueriesRelationships
addHasWhere(Builder $hasQuery, Relation $relation, string $operator, int $count, string $boolean)
Add the "has" condition where clause to the query.
Builder|QueriesRelationships
mergeConstraintsFrom(Builder $from)
Merge the where constraints from another query to the current query.
protected array
requalifyWhereTables(array $wheres, string $from, string $to)
Updates the table name for any columns with a new qualified name.
protected $this
addWhereCountQuery(Builder $query, string $operator = '>=', int $count = 1, string $boolean = 'and')
Add a sub-query count clause to this query.
protected Relation
getRelationWithoutConstraints(string $relation)
Get the "has relation" base query instance.
protected bool
canUseExistsForExistenceCheck(string $operator, int $count)
Check if we can run an "exists" query to optimize performance.
void
__construct(Builder $query)
Create a new Eloquent query builder instance.
$this
withoutGlobalScope(Scope|string $scope)
Remove a registered global scope.
$this
withoutGlobalScopes(array $scopes = null)
Remove all or passed registered global scopes.
array
removedScopes()
Get an array of global scopes that were removed from the query.
$this
whereKey(mixed $id)
Add a where clause on the primary key to the query.
$this
whereKeyNot(mixed $id)
Add a where clause on the primary key to the query.
$this
where(Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')
Add a basic where clause to the query.
Model|Builder|null
firstWhere(Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')
Add a basic where clause to the query, and return the first result.
$this
orWhere(Closure|array|string|Expression $column, mixed $operator = null, mixed $value = null)
Add an "or where" clause to the query.
$this
whereNot(Closure|string|array|Expression $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')
Add a basic "where not" clause to the query.
$this
orWhereNot(Closure|array|string|Expression $column, mixed $operator = null, mixed $value = null)
Add an "or where not" clause to the query.
$this
latest(string|Expression $column = null)
Add an "order by" clause for a timestamp to the query.
$this
oldest(string|Expression $column = null)
Add an "order by" clause for a timestamp to the query.
Collection
hydrate(array $items)
Create a collection of models from plain arrays.
Collection
fromQuery(string $query, array $bindings = [])
Create a collection of models from a raw query.
Model|Collection|Builder[]|Builder|null
find(mixed $id, array|string $columns = ['*'])
Find a model by its primary key.
Collection
findMany(Arrayable|array $ids, array|string $columns = ['*'])
Find multiple models by their primary keys.
Model|Collection|Builder|Builder[]
findOrFail(mixed $id, array|string $columns = ['*'])
Find a model by its primary key or throw an exception.
Model|Builder
findOrNew(mixed $id, array|string $columns = ['*'])
Find a model by its primary key or return fresh model instance.
Model|Collection|Builder[]|Builder|mixed
findOr(mixed $id, Closure|array|string $columns = ['*'], Closure $callback = null)
Find a model by its primary key or call a callback.
Model|Builder
firstOrNew(array $attributes = [], array $values = [])
Get the first record matching the attributes or instantiate it.
Model|Builder
firstOrCreate(array $attributes = [], array $values = [])
Get the first record matching the attributes. If the record is not found, create it.
Model|Builder
createOrFirst(array $attributes = [], array $values = [])
Attempt to create the record. If a unique constraint violation occurs, attempt to find the matching record.
Model|Builder
updateOrCreate(array $attributes, array $values = [])
Create or update a record matching the attributes, and fill it with values.
Model|Builder
firstOrFail(array|string $columns = ['*'])
Execute the query and get the first result or throw an exception.
Model|Builder|mixed
firstOr(Closure|array|string $columns = ['*'], Closure $callback = null)
Execute the query and get the first result or call a callback.
mixed
value(string|Expression $column)
Get a single column's value from the first result of a query.
mixed
soleValue(string|Expression $column)
Get a single column's value from the first result of a query if it's the sole matching record.
mixed
valueOrFail(string|Expression $column)
Get a single column's value from the first result of the query or throw an exception.
Collection|Builder[]
get(array|string $columns = ['*'])
Execute the query as a "select" statement.
Model[]|Builder[]
getModels(array|string $columns = ['*'])
Get the hydrated models without eager loading.
array
eagerLoadRelations(array $models)
Eager load the relationships for the models.
protected array
eagerLoadRelation(array $models, string $name, Closure $constraints)
Eagerly load the relationship on a set of models.
Relation
getRelation(string $name)
Get the relation instance for the given relation name.
protected array
relationsNestedUnder(string $relation)
Get the deeply nested relations for a given top-level relation.
protected bool
isNestedUnder(string $relation, string $name)
Determine if the relationship is nested.
LazyCollection
cursor()
Get a lazy collection for the given query.
protected void
enforceOrderBy()
Add a generic "order by" clause if the query doesn't already have one.
Collection
pluck(string|Expression $column, string|null $key = null)
Get a collection with the values of a given column.
LengthAwarePaginator
paginate(int|null|Closure $perPage = null, array|string $columns = ['*'], string $pageName = 'page', int|null $page = null)
Paginate the given query.
Paginator
simplePaginate(int|null $perPage = null, array|string $columns = ['*'], string $pageName = 'page', int|null $page = null)
Paginate the given query into a simple paginator.
CursorPaginator
cursorPaginate(int|null $perPage = null, array|string $columns = ['*'], string $cursorName = 'cursor', Cursor|string|null $cursor = null)
Paginate the given query into a cursor paginator.
protected Collection
ensureOrderForCursorPagination(bool $shouldReverse = false)
Ensure the proper order by required for cursor pagination.
Model|$this
create(array $attributes = [])
Save a new model and return the instance.
Model|$this
forceCreate(array $attributes)
Save a new model and return the instance. Allow mass-assignment.
Model|$this
forceCreateQuietly(array $attributes = [])
Save a new model instance with mass assignment without raising model events.
int
update(array $values)
Update records in the database.
int
upsert(array $values, array|string $uniqueBy, array|null $update = null)
Insert new records or update the existing ones.
int|false
touch(string|null $column = null)
Update the column's update timestamp.
int
increment(string|Expression $column, float|int $amount = 1, array $extra = [])
Increment a column's value by a given amount.
int
decrement(string|Expression $column, float|int $amount = 1, array $extra = [])
Decrement a column's value by a given amount.
protected array
addUpdatedAtColumn(array $values)
Add the "updated at" column to an array of values.
protected array
addUniqueIdsToUpsertValues(array $values)
Add unique IDs to the inserted values.
protected array
addTimestampsToUpsertValues(array $values)
Add timestamps to the inserted values.
protected array
addUpdatedAtToUpsertColumns(array $update)
Add the "updated at" column to the updated columns.
mixed
delete()
Delete records from the database.
mixed
forceDelete()
Run the default delete function on the builder.
Since we do not apply scopes here, the row will actually be deleted.
void
onDelete(Closure $callback)
Register a replacement for the default delete function.
bool
hasNamedScope(string $scope)
Determine if the given model has a scope.
Builder|mixed
scopes(array|string $scopes)
Call the given local model scopes.
Builder
applyScopes()
Apply the scopes to the Eloquent builder instance and return it.
protected mixed
callScope(callable $scope, array $parameters = [])
Apply the given scope on the current builder instance.
protected mixed
callNamedScope(string $scope, array $parameters = [])
Apply the given named scope on the current builder instance.
protected void
addNewWheresWithinGroup(Builder $query, int $originalWhereCount)
Nest where conditions by slicing them at the given where count.
protected void
groupWhereSliceForScope(Builder $query, array $whereSlice)
Slice where conditions at the given offset and add them to the query as a nested condition.
protected array
createNestedWhere(array $whereSlice, string $boolean = 'and')
Create a where array with nested where conditions.
$this
with(string|array $relations, string|Closure|null $callback = null)
Set the relationships that should be eager loaded.
$this
without(mixed $relations)
Prevent the specified relations from being eager loaded.
$this
withOnly(mixed $relations)
Set the relationships that should be eager loaded while removing any previously added eager loading specifications.
Model|Builder
newModelInstance(array $attributes = [])
Create a new instance of the model being queried.
protected array
parseWithRelations(array $relations)
Parse a list of relations into individuals.
protected array
prepareNestedWithRelationships(array $relations, string $prefix = '')
Prepare nested with relationships.
protected Closure
combineConstraints(array $constraints)
Combine an array of constraints into a single constraint.
protected array
parseNameAndAttributeSelectionConstraint(string $name)
Parse the attribute select constraints from the name.
protected array
createSelectWithConstraint(string $name)
Create a constraint to select the given columns for the relation.
protected array
addNestedWiths(string $name, array $results)
Parse the nested relationships in a relation.
$this
withCasts(array $casts)
Apply query-time casts to the model instance.
mixed
withSavepointIfNeeded(Closure $scope)
No description
protected Collection
getUnionBuilders()
Get the Eloquent builder instances that are used in the union of the query.
Builder
getQuery()
Get the underlying query builder instance.
$this
setQuery(Builder $query)
Set the underlying query builder instance.
Builder
toBase()
Get a base query builder instance.
array
getEagerLoads()
Get the relationships being eagerly loaded.
$this
setEagerLoads(array $eagerLoad)
Set the relationships being eagerly loaded.
$this
withoutEagerLoad(array $relations)
Indicate that the given relationships should not be eagerly loaded.
$this
withoutEagerLoads()
Flush the relationships being eagerly loaded.
protected string
defaultKeyName()
Get the default key name of the table.
$this
setModel(Model $model)
Set a model instance for the model being queried.
string
qualifyColumn(string|Expression $column)
Qualify the given column name by the model's table.
array
qualifyColumns(array|Expression $columns)
Qualify the given columns with the model's table.
Closure
getMacro(string $name)
Get the given macro by name.
bool
hasMacro(string $name)
Checks if a macro is registered.
static Closure
getGlobalMacro(string $name)
Get the given global macro by name.
static bool
hasGlobalMacro(string $name)
Checks if a global macro is registered.
mixed
__get(string $key)
Dynamically access builder proxies.
mixed
__call(string $method, array $parameters)
Dynamically handle calls into the query instance.
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls into the query instance.
static protected void
registerMixin(string $mixin, bool $replace)
Register the given mixin with the builder.
Builder
clone()
Clone the Eloquent query builder.
void
__clone()
Force a clone of the underlying query builder when cloning.