Builder
extends Builder
in package
Query builder class.
Extends Eloquent builder class.
Tags
Table of Contents
- $eagerLoad : array<string|int, mixed>
- The relationships that should be eager loaded.
- $localMacros : array<string|int, mixed>
- All of the locally registered builder macros.
- $macros : array<string|int, mixed>
- All of the globally registered builder macros.
- $model : Model
- The model being queried.
- $onDelete : Closure
- A replacement for the typical delete function.
- $passthru : array<string|int, mixed>
- The methods that should be returned from query builder.
- $query : Builder
- The base query builder instance.
- $removedScopes : array<string|int, mixed>
- Removed global scopes.
- $scopes : array<string|int, mixed>
- Applied global scopes.
- __call() : mixed
- Dynamically handle calls into the query instance.
- __callStatic() : mixed
- Dynamically handle calls into the query instance.
- __clone() : void
- Force a clone of the underlying query builder when cloning.
- __construct() : void
- Create a new Eloquent query builder instance.
- applyScopes() : Builder|static
- Apply the scopes to the Eloquent builder instance and return it.
- chunk() : bool
- Chunk the results of the query.
- chunkById() : bool
- Chunk the results of a query by comparing numeric IDs.
- create() : Model|$this
- Save a new model and return the instance.
- cursor() : Generator
- Get a generator for the given query.
- decrement() : int
- Decrement a column's value by a given amount.
- delete() : mixed
- Delete a record from the database.
- doesntHave() : Builder|static
- Add a relationship count / exists condition to the query.
- each() : bool
- Execute a callback over each item while chunking.
- eagerLoadRelations() : array<string|int, mixed>
- Eager load the relationships for the models.
- find() : Model|Collection|array<string|int, static>|static|null
- Find a model by its primary key.
- findMany() : Collection
- Find multiple models by their primary keys.
- findOrFail() : Model|Collection
- Find a model by its primary key or throw an exception.
- findOrNew() : Model
- Find a model by its primary key or return fresh model instance.
- first() : Model|object|static|null
- Execute the query and get the first result.
- firstOr() : Model|static|mixed
- Execute the query and get the first result or call a callback.
- firstOrCreate() : Model
- Get the first record matching the attributes or create it.
- firstOrFail() : Model|static
- Execute the query and get the first result or throw an exception.
- firstOrNew() : Model
- Get the first record matching the attributes or instantiate it.
- forceCreate() : Model|$this
- Save a new model and return the instance. Allow mass-assignment.
- forceDelete() : mixed
- Run the default delete function on the builder.
- fromQuery() : Collection
- Create a collection of models from a raw query.
- get() : Collection|array<string|int, static>
- Execute the query as a "select" statement.
- getEagerLoads() : array<string|int, mixed>
- Get the relationships being eagerly loaded.
- getMacro() : Closure
- Get the given macro by name.
- getModel() : Model
- Get the model instance being queried.
- getModels() : array<string|int, Model>
- Get the hydrated models without eager loading.
- getQuery() : Builder
- Get the underlying query builder instance.
- getRelation() : Relation
- Get the relation instance for the given relation name.
- has() : Builder|static
- Add a relationship count / exists condition to the query.
- hydrate() : Collection
- Create a collection of models from plain arrays.
- increment() : int
- Increment a column's value by a given amount.
- lists() : array<string|int, mixed>
- Get an array with the values of a given column.
- make() : Model
- Create and return an un-saved model instance.
- mergeConstraintsFrom() : Builder|static
- Merge the where constraints from another query to the current query.
- newModelInstance() : Model
- Create a new instance of the model being queried.
- onDelete() : void
- Register a replacement for the default delete function.
- orDoesntHave() : Builder|static
- Add a relationship count / exists condition to the query with an "or".
- orHas() : Builder|static
- Add a relationship count / exists condition to the query with an "or".
- orSearchWhere() : self
- Add an "or search where" clause to the query.
- orWhere() : Builder|static
- Add an "or where" clause to the query.
- orWhereDoesntHave() : Builder|static
- Add a relationship count / exists condition to the query with where clauses and an "or".
- orWhereHas() : Builder|static
- Add a relationship count / exists condition to the query with where clauses and an "or".
- paginate() : LengthAwarePaginator
- Paginate the given query.
- pluck() : Collection
- Get an array with the values of a given column.
- qualifyColumn() : string
- Qualify the given column name by the model's table.
- removedScopes() : array<string|int, mixed>
- Get an array of global scopes that were removed from the query.
- scopes() : mixed
- Call the given local model scopes.
- searchWhere() : self
- Perform a search on this query for term found in columns.
- setEagerLoads() : $this
- Set the relationships being eagerly loaded.
- setModel() : $this
- Set a model instance for the model being queried.
- setQuery() : $this
- Set the underlying query builder instance.
- simplePaginate() : Paginator
- Paginate the given query into a simple paginator.
- tap() : Builder
- Pass the query to a given callback.
- toBase() : Builder
- Get a base query builder instance.
- unless() : mixed
- Apply the callback's query changes if the given "value" is false.
- update() : int
- Update a record in the database.
- updateOrCreate() : Model
- Create or update a record matching the attributes, and fill it with values.
- value() : mixed
- Get a single column's value from the first result of a query.
- when() : mixed
- Apply the callback's query changes if the given "value" is true.
- where() : $this
- Add a basic where clause to the query.
- whereDoesntHave() : Builder|static
- Add a relationship count / exists condition to the query with where clauses.
- whereHas() : Builder|static
- Add a relationship count / exists condition to the query with where clauses.
- whereKey() : $this
- Add a where clause on the primary key to the query.
- whereKeyNot() : $this
- Add a where clause on the primary key to the query.
- with() : $this
- Set the relationships that should be eager loaded.
- withCount() : $this
- Add subselect queries to count the relations.
- withGlobalScope() : $this
- Register a new global scope.
- without() : $this
- Prevent the specified relations from being eager loaded.
- withoutGlobalScope() : $this
- Remove a registered global scope.
- withoutGlobalScopes() : $this
- Remove all or passed registered global scopes.
- addHasWhere() : Builder|static
- Add the "has" condition where clause to the query.
- addNestedWiths() : array<string|int, mixed>
- Parse the nested relationships in a relation.
- addNewWheresWithinGroup() : void
- Nest where conditions by slicing them at the given where count.
- addUpdatedAtColumn() : array<string|int, mixed>
- Add the "updated at" column to an array of values.
- addWhereCountQuery() : $this
- Add a sub-query count clause to this query.
- callScope() : mixed
- Apply the given scope on the current builder instance.
- canUseExistsForExistenceCheck() : bool
- Check if we can run an "exists" query to optimize performance.
- createNestedWhere() : array<string|int, mixed>
- Create a where array with nested where conditions.
- createSelectWithConstraint() : array<string|int, mixed>
- Create a constraint to select the given columns for the relation.
- eagerLoadRelation() : array<string|int, mixed>
- Eagerly load the relationship on a set of models.
- enforceOrderBy() : void
- Add a generic "order by" clause if the query doesn't already have one.
- getRelationWithoutConstraints() : Relation
- Get the "has relation" base query instance.
- groupWhereSliceForScope() : void
- Slice where conditions at the given offset and add them to the query as a nested condition.
- hasNested() : Builder|static
- Add nested relationship count / exists conditions to the query.
- isNestedUnder() : bool
- Determine if the relationship is nested.
- paginator() : LengthAwarePaginator
- Create a new length-aware paginator instance.
- parseWithRelations() : array<string|int, mixed>
- Parse a list of relations into individuals.
- relationsNestedUnder() : array<string|int, mixed>
- Get the deeply nested relations for a given top-level relation.
- searchWhereInternal() : mixed
- Internal method to apply a search constraint to the query.
- simplePaginator() : Paginator
- Create a new simple paginator instance.
Properties
$eagerLoad
The relationships that should be eager loaded.
protected
array<string|int, mixed>
$eagerLoad
= []
$localMacros
All of the locally registered builder macros.
protected
array<string|int, mixed>
$localMacros
= []
$macros
All of the globally registered builder macros.
protected
static array<string|int, mixed>
$macros
= []
$model
The model being queried.
protected
Model
$model
$onDelete
A replacement for the typical delete function.
protected
Closure
$onDelete
$passthru
The methods that should be returned from query builder.
protected
array<string|int, mixed>
$passthru
= ['insert', 'insertGetId', 'getBindings', 'toSql', 'exists', 'doesntExist', 'count', 'min', 'max', 'avg', 'sum', 'getConnection']
$query
The base query builder instance.
protected
Builder
$query
$removedScopes
Removed global scopes.
protected
array<string|int, mixed>
$removedScopes
= []
$scopes
Applied global scopes.
protected
array<string|int, mixed>
$scopes
= []
Methods
__call()
Dynamically handle calls into the query instance.
public
__call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
- $method : string
- $parameters : array<string|int, mixed>
Return values
mixed —__callStatic()
Dynamically handle calls into the query instance.
public
static __callStatic(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
- $method : string
- $parameters : array<string|int, mixed>
Tags
Return values
mixed —__clone()
Force a clone of the underlying query builder when cloning.
public
__clone() : void
Return values
void —__construct()
Create a new Eloquent query builder instance.
public
__construct(Builder $query) : void
Parameters
- $query : Builder
Return values
void —applyScopes()
Apply the scopes to the Eloquent builder instance and return it.
public
applyScopes() : Builder|static
Return values
Builder|static —chunk()
Chunk the results of the query.
public
chunk(int $count, callable $callback) : bool
Parameters
- $count : int
- $callback : callable
Return values
bool —chunkById()
Chunk the results of a query by comparing numeric IDs.
public
chunkById(int $count, callable $callback[, string $column = null ][, string|null $alias = null ]) : bool
Parameters
- $count : int
- $callback : callable
- $column : string = null
- $alias : string|null = null
Return values
bool —create()
Save a new model and return the instance.
public
create([array<string|int, mixed> $attributes = [] ]) : Model|$this
Parameters
- $attributes : array<string|int, mixed> = []
Return values
Model|$this —cursor()
Get a generator for the given query.
public
cursor() : Generator
Return values
Generator —decrement()
Decrement a column's value by a given amount.
public
decrement(string $column[, int $amount = 1 ][, array<string|int, mixed> $extra = [] ]) : int
Parameters
- $column : string
- $amount : int = 1
- $extra : array<string|int, mixed> = []
Return values
int —delete()
Delete a record from the database.
public
delete() : mixed
Return values
mixed —doesntHave()
Add a relationship count / exists condition to the query.
public
doesntHave(string $relation[, string $boolean = 'and' ][, Closure|null $callback = null ]) : Builder|static
Parameters
- $relation : string
- $boolean : string = 'and'
- $callback : Closure|null = null
Return values
Builder|static —each()
Execute a callback over each item while chunking.
public
each(callable $callback[, int $count = 1000 ]) : bool
Parameters
- $callback : callable
- $count : int = 1000
Return values
bool —eagerLoadRelations()
Eager load the relationships for the models.
public
eagerLoadRelations(array<string|int, mixed> $models) : array<string|int, mixed>
Parameters
- $models : array<string|int, mixed>
Return values
array<string|int, mixed> —find()
Find a model by its primary key.
public
find(mixed $id[, array<string|int, mixed> $columns = ['*'] ]) : Model|Collection|array<string|int, static>|static|null
Parameters
- $id : mixed
- $columns : array<string|int, mixed> = ['*']
Return values
Model|Collection|array<string|int, static>|static|null —findMany()
Find multiple models by their primary keys.
public
findMany(Arrayable|array<string|int, mixed> $ids[, array<string|int, mixed> $columns = ['*'] ]) : Collection
Parameters
- $ids : Arrayable|array<string|int, mixed>
- $columns : array<string|int, mixed> = ['*']
Return values
Collection —findOrFail()
Find a model by its primary key or throw an exception.
public
findOrFail(mixed $id[, array<string|int, mixed> $columns = ['*'] ]) : Model|Collection
Parameters
- $id : mixed
- $columns : array<string|int, mixed> = ['*']
Tags
Return values
Model|Collection —findOrNew()
Find a model by its primary key or return fresh model instance.
public
findOrNew(mixed $id[, array<string|int, mixed> $columns = ['*'] ]) : Model
Parameters
- $id : mixed
- $columns : array<string|int, mixed> = ['*']
Return values
Model —first()
Execute the query and get the first result.
public
first([array<string|int, mixed> $columns = ['*'] ]) : Model|object|static|null
Parameters
- $columns : array<string|int, mixed> = ['*']
Return values
Model|object|static|null —firstOr()
Execute the query and get the first result or call a callback.
public
firstOr([Closure|array<string|int, mixed> $columns = ['*'] ][, Closure|null $callback = null ]) : Model|static|mixed
Parameters
- $columns : Closure|array<string|int, mixed> = ['*']
- $callback : Closure|null = null
Return values
Model|static|mixed —firstOrCreate()
Get the first record matching the attributes or create it.
public
firstOrCreate(array<string|int, mixed> $attributes[, array<string|int, mixed> $values = [] ]) : Model
Parameters
- $attributes : array<string|int, mixed>
- $values : array<string|int, mixed> = []
Return values
Model —firstOrFail()
Execute the query and get the first result or throw an exception.
public
firstOrFail([array<string|int, mixed> $columns = ['*'] ]) : Model|static
Parameters
- $columns : array<string|int, mixed> = ['*']
Tags
Return values
Model|static —firstOrNew()
Get the first record matching the attributes or instantiate it.
public
firstOrNew(array<string|int, mixed> $attributes[, array<string|int, mixed> $values = [] ]) : Model
Parameters
- $attributes : array<string|int, mixed>
- $values : array<string|int, mixed> = []
Return values
Model —forceCreate()
Save a new model and return the instance. Allow mass-assignment.
public
forceCreate(array<string|int, mixed> $attributes) : Model|$this
Parameters
- $attributes : array<string|int, mixed>
Return values
Model|$this —forceDelete()
Run the default delete function on the builder.
public
forceDelete() : mixed
Since we do not apply scopes here, the row will actually be deleted.
Return values
mixed —fromQuery()
Create a collection of models from a raw query.
public
fromQuery(string $query[, array<string|int, mixed> $bindings = [] ]) : Collection
Parameters
- $query : string
- $bindings : array<string|int, mixed> = []
Return values
Collection —get()
Execute the query as a "select" statement.
public
get([array<string|int, mixed> $columns = ['*'] ]) : Collection|array<string|int, static>
Parameters
- $columns : array<string|int, mixed> = ['*']
Return values
Collection|array<string|int, static> —getEagerLoads()
Get the relationships being eagerly loaded.
public
getEagerLoads() : array<string|int, mixed>
Return values
array<string|int, mixed> —getMacro()
Get the given macro by name.
public
getMacro(string $name) : Closure
Parameters
- $name : string
Return values
Closure —getModel()
Get the model instance being queried.
public
getModel() : Model
Return values
Model —getModels()
Get the hydrated models without eager loading.
public
getModels([array<string|int, mixed> $columns = ['*'] ]) : array<string|int, Model>
Parameters
- $columns : array<string|int, mixed> = ['*']
Return values
array<string|int, Model> —getQuery()
Get the underlying query builder instance.
public
getQuery() : Builder
Return values
Builder —getRelation()
Get the relation instance for the given relation name.
public
getRelation(string $name) : Relation
Parameters
- $name : string
Return values
Relation —has()
Add a relationship count / exists condition to the query.
public
has(string $relation[, string $operator = '>=' ][, int $count = 1 ][, string $boolean = 'and' ][, Closure|null $callback = null ]) : Builder|static
Parameters
- $relation : string
- $operator : string = '>='
- $count : int = 1
- $boolean : string = 'and'
- $callback : Closure|null = null
Return values
Builder|static —hydrate()
Create a collection of models from plain arrays.
public
hydrate(array<string|int, mixed> $items) : Collection
Parameters
- $items : array<string|int, mixed>
Return values
Collection —increment()
Increment a column's value by a given amount.
public
increment(string $column[, int $amount = 1 ][, array<string|int, mixed> $extra = [] ]) : int
Parameters
- $column : string
- $amount : int = 1
- $extra : array<string|int, mixed> = []
Return values
int —lists()
Get an array with the values of a given column.
public
lists(string $column[, string|null $key = null ]) : array<string|int, mixed>
Parameters
- $column : string
- $key : string|null = null
Return values
array<string|int, mixed> —make()
Create and return an un-saved model instance.
public
make([array<string|int, mixed> $attributes = [] ]) : Model
Parameters
- $attributes : array<string|int, mixed> = []
Return values
Model —mergeConstraintsFrom()
Merge the where constraints from another query to the current query.
public
mergeConstraintsFrom(Builder $from) : Builder|static
Parameters
- $from : Builder
Return values
Builder|static —newModelInstance()
Create a new instance of the model being queried.
public
newModelInstance([array<string|int, mixed> $attributes = [] ]) : Model
Parameters
- $attributes : array<string|int, mixed> = []
Return values
Model —onDelete()
Register a replacement for the default delete function.
public
onDelete(Closure $callback) : void
Parameters
- $callback : Closure
Return values
void —orDoesntHave()
Add a relationship count / exists condition to the query with an "or".
public
orDoesntHave(string $relation) : Builder|static
Parameters
- $relation : string
Return values
Builder|static —orHas()
Add a relationship count / exists condition to the query with an "or".
public
orHas(string $relation[, string $operator = '>=' ][, int $count = 1 ]) : Builder|static
Parameters
- $relation : string
- $operator : string = '>='
- $count : int = 1
Return values
Builder|static —orSearchWhere()
Add an "or search where" clause to the query.
public
orSearchWhere(string $term[, array<string|int, mixed> $columns = [] ][, string $mode = 'all' ]) : self
Parameters
- $term : string
-
Search query
- $columns : array<string|int, mixed> = []
-
Table columns to search
- $mode : string = 'all'
-
Search mode: all, any, exact.
Return values
self —orWhere()
Add an "or where" clause to the query.
public
orWhere(Closure|array<string|int, mixed>|string $column[, string $operator = null ][, mixed $value = null ]) : Builder|static
Parameters
- $column : Closure|array<string|int, mixed>|string
- $operator : string = null
- $value : mixed = null
Return values
Builder|static —orWhereDoesntHave()
Add a relationship count / exists condition to the query with where clauses and an "or".
public
orWhereDoesntHave(string $relation[, Closure $callback = null ]) : Builder|static
Parameters
- $relation : string
- $callback : Closure = null
Return values
Builder|static —orWhereHas()
Add a relationship count / exists condition to the query with where clauses and an "or".
public
orWhereHas(string $relation[, Closure $callback = null ][, string $operator = '>=' ][, int $count = 1 ]) : Builder|static
Parameters
- $relation : string
- $callback : Closure = null
- $operator : string = '>='
- $count : int = 1
Return values
Builder|static —paginate()
Paginate the given query.
public
paginate([int $perPage = null ][, int $currentPage = null ][, array<string|int, mixed> $columns = ['*'] ][, string $pageName = 'page' ]) : LengthAwarePaginator
Parameters
- $perPage : int = null
- $currentPage : int = null
- $columns : array<string|int, mixed> = ['*']
- $pageName : string = 'page'
Return values
LengthAwarePaginator —pluck()
Get an array with the values of a given column.
public
pluck(string $column[, string|null $key = null ]) : Collection
Parameters
- $column : string
- $key : string|null = null
Return values
Collection —qualifyColumn()
Qualify the given column name by the model's table.
public
qualifyColumn(string $column) : string
Parameters
- $column : string
Return values
string —removedScopes()
Get an array of global scopes that were removed from the query.
public
removedScopes() : array<string|int, mixed>
Return values
array<string|int, mixed> —scopes()
Call the given local model scopes.
public
scopes(array<string|int, mixed> $scopes) : mixed
Parameters
- $scopes : array<string|int, mixed>
Return values
mixed —searchWhere()
Perform a search on this query for term found in columns.
public
searchWhere(string $term[, array<string|int, mixed> $columns = [] ][, string $mode = 'all' ]) : self
Parameters
- $term : string
-
Search query
- $columns : array<string|int, mixed> = []
-
Table columns to search
- $mode : string = 'all'
-
Search mode: all, any, exact.
Return values
self —setEagerLoads()
Set the relationships being eagerly loaded.
public
setEagerLoads(array<string|int, mixed> $eagerLoad) : $this
Parameters
- $eagerLoad : array<string|int, mixed>
Return values
$this —setModel()
Set a model instance for the model being queried.
public
setModel(Model $model) : $this
Parameters
- $model : Model
Return values
$this —setQuery()
Set the underlying query builder instance.
public
setQuery(Builder $query) : $this
Parameters
- $query : Builder
Return values
$this —simplePaginate()
Paginate the given query into a simple paginator.
public
simplePaginate([int $perPage = null ][, int $currentPage = null ][, array<string|int, mixed> $columns = ['*'] ][, mixed $pageName = 'page' ]) : Paginator
Parameters
- $perPage : int = null
- $currentPage : int = null
- $columns : array<string|int, mixed> = ['*']
- $pageName : mixed = 'page'
Return values
Paginator —tap()
Pass the query to a given callback.
public
tap(Closure $callback) : Builder
Parameters
- $callback : Closure
Return values
Builder —toBase()
Get a base query builder instance.
public
toBase() : Builder
Return values
Builder —unless()
Apply the callback's query changes if the given "value" is false.
public
unless(mixed $value, callable $callback[, callable $default = null ]) : mixed
Parameters
- $value : mixed
- $callback : callable
- $default : callable = null
Return values
mixed —update()
Update a record in the database.
public
update(array<string|int, mixed> $values) : int
Parameters
- $values : array<string|int, mixed>
Return values
int —updateOrCreate()
Create or update a record matching the attributes, and fill it with values.
public
updateOrCreate(array<string|int, mixed> $attributes[, array<string|int, mixed> $values = [] ]) : Model
Parameters
- $attributes : array<string|int, mixed>
- $values : array<string|int, mixed> = []
Return values
Model —value()
Get a single column's value from the first result of a query.
public
value(string $column) : mixed
Parameters
- $column : string
Return values
mixed —when()
Apply the callback's query changes if the given "value" is true.
public
when(mixed $value, callable $callback[, callable $default = null ]) : mixed
Parameters
- $value : mixed
- $callback : callable
- $default : callable = null
Return values
mixed —where()
Add a basic where clause to the query.
public
where(string|array<string|int, mixed>|Closure $column[, string $operator = null ][, mixed $value = null ][, string $boolean = 'and' ]) : $this
Parameters
- $column : string|array<string|int, mixed>|Closure
- $operator : string = null
- $value : mixed = null
- $boolean : string = 'and'
Return values
$this —whereDoesntHave()
Add a relationship count / exists condition to the query with where clauses.
public
whereDoesntHave(string $relation[, Closure|null $callback = null ]) : Builder|static
Parameters
- $relation : string
- $callback : Closure|null = null
Return values
Builder|static —whereHas()
Add a relationship count / exists condition to the query with where clauses.
public
whereHas(string $relation[, Closure|null $callback = null ][, string $operator = '>=' ][, int $count = 1 ]) : Builder|static
Parameters
- $relation : string
- $callback : Closure|null = null
- $operator : string = '>='
- $count : int = 1
Return values
Builder|static —whereKey()
Add a where clause on the primary key to the query.
public
whereKey(mixed $id) : $this
Parameters
- $id : mixed
Return values
$this —whereKeyNot()
Add a where clause on the primary key to the query.
public
whereKeyNot(mixed $id) : $this
Parameters
- $id : mixed
Return values
$this —with()
Set the relationships that should be eager loaded.
public
with(mixed $relations) : $this
Parameters
- $relations : mixed
Return values
$this —withCount()
Add subselect queries to count the relations.
public
withCount(mixed $relations) : $this
Parameters
- $relations : mixed
Return values
$this —withGlobalScope()
Register a new global scope.
public
withGlobalScope(string $identifier, Scope|Closure $scope) : $this
Parameters
- $identifier : string
- $scope : Scope|Closure
Return values
$this —without()
Prevent the specified relations from being eager loaded.
public
without(mixed $relations) : $this
Parameters
- $relations : mixed
Return values
$this —withoutGlobalScope()
Remove a registered global scope.
public
withoutGlobalScope(Scope|string $scope) : $this
Parameters
- $scope : Scope|string
Return values
$this —withoutGlobalScopes()
Remove all or passed registered global scopes.
public
withoutGlobalScopes([array<string|int, mixed>|null $scopes = null ]) : $this
Parameters
- $scopes : array<string|int, mixed>|null = null
Return values
$this —addHasWhere()
Add the "has" condition where clause to the query.
protected
addHasWhere(Builder $hasQuery, Relation $relation, string $operator, int $count, string $boolean) : Builder|static
Parameters
Return values
Builder|static —addNestedWiths()
Parse the nested relationships in a relation.
protected
addNestedWiths(string $name, array<string|int, mixed> $results) : array<string|int, mixed>
Parameters
- $name : string
- $results : array<string|int, mixed>
Return values
array<string|int, mixed> —addNewWheresWithinGroup()
Nest where conditions by slicing them at the given where count.
protected
addNewWheresWithinGroup(Builder $query, int $originalWhereCount) : void
Parameters
- $query : Builder
- $originalWhereCount : int
Return values
void —addUpdatedAtColumn()
Add the "updated at" column to an array of values.
protected
addUpdatedAtColumn(array<string|int, mixed> $values) : array<string|int, mixed>
Parameters
- $values : array<string|int, mixed>
Return values
array<string|int, mixed> —addWhereCountQuery()
Add a sub-query count clause to this query.
protected
addWhereCountQuery(Builder $query[, string $operator = '>=' ][, int $count = 1 ][, string $boolean = 'and' ]) : $this
Parameters
- $query : Builder
- $operator : string = '>='
- $count : int = 1
- $boolean : string = 'and'
Return values
$this —callScope()
Apply the given scope on the current builder instance.
protected
callScope(callable $scope[, array<string|int, mixed> $parameters = [] ]) : mixed
Parameters
- $scope : callable
- $parameters : array<string|int, mixed> = []
Return values
mixed —canUseExistsForExistenceCheck()
Check if we can run an "exists" query to optimize performance.
protected
canUseExistsForExistenceCheck(string $operator, int $count) : bool
Parameters
- $operator : string
- $count : int
Return values
bool —createNestedWhere()
Create a where array with nested where conditions.
protected
createNestedWhere(array<string|int, mixed> $whereSlice[, string $boolean = 'and' ]) : array<string|int, mixed>
Parameters
- $whereSlice : array<string|int, mixed>
- $boolean : string = 'and'
Return values
array<string|int, mixed> —createSelectWithConstraint()
Create a constraint to select the given columns for the relation.
protected
createSelectWithConstraint(string $name) : array<string|int, mixed>
Parameters
- $name : string
Return values
array<string|int, mixed> —eagerLoadRelation()
Eagerly load the relationship on a set of models.
protected
eagerLoadRelation(array<string|int, mixed> $models, string $name, Closure $constraints) : array<string|int, mixed>
Parameters
- $models : array<string|int, mixed>
- $name : string
- $constraints : Closure
Return values
array<string|int, mixed> —enforceOrderBy()
Add a generic "order by" clause if the query doesn't already have one.
protected
enforceOrderBy() : void
Return values
void —getRelationWithoutConstraints()
Get the "has relation" base query instance.
protected
getRelationWithoutConstraints(string $relation) : Relation
Parameters
- $relation : string
Return values
Relation —groupWhereSliceForScope()
Slice where conditions at the given offset and add them to the query as a nested condition.
protected
groupWhereSliceForScope(Builder $query, array<string|int, mixed> $whereSlice) : void
Parameters
- $query : Builder
- $whereSlice : array<string|int, mixed>
Return values
void —hasNested()
Add nested relationship count / exists conditions to the query.
protected
hasNested(string $relations[, string $operator = '>=' ][, int $count = 1 ][, string $boolean = 'and' ][, Closure|null $callback = null ]) : Builder|static
Sets up recursive call to whereHas until we finish the nested relation.
Parameters
- $relations : string
- $operator : string = '>='
- $count : int = 1
- $boolean : string = 'and'
- $callback : Closure|null = null
Return values
Builder|static —isNestedUnder()
Determine if the relationship is nested.
protected
isNestedUnder(string $relation, string $name) : bool
Parameters
- $relation : string
- $name : string
Return values
bool —paginator()
Create a new length-aware paginator instance.
protected
paginator(Collection $items, int $total, int $perPage, int $currentPage, array<string|int, mixed> $options) : LengthAwarePaginator
Parameters
- $items : Collection
- $total : int
- $perPage : int
- $currentPage : int
- $options : array<string|int, mixed>
Return values
LengthAwarePaginator —parseWithRelations()
Parse a list of relations into individuals.
protected
parseWithRelations(array<string|int, mixed> $relations) : array<string|int, mixed>
Parameters
- $relations : array<string|int, mixed>
Return values
array<string|int, mixed> —relationsNestedUnder()
Get the deeply nested relations for a given top-level relation.
protected
relationsNestedUnder(string $relation) : array<string|int, mixed>
Parameters
- $relation : string
Return values
array<string|int, mixed> —searchWhereInternal()
Internal method to apply a search constraint to the query.
protected
searchWhereInternal(mixed $term, mixed $columns, mixed $mode, mixed $boolean) : mixed
Mode can be any of these options:
- all: result must contain all words
- any: result can contain any word
- exact: result must contain the exact phrase
Parameters
- $term : mixed
- $columns : mixed
- $mode : mixed
- $boolean : mixed
Return values
mixed —simplePaginator()
Create a new simple paginator instance.
protected
simplePaginator(Collection $items, int $perPage, int $currentPage, array<string|int, mixed> $options) : Paginator
Parameters
- $items : Collection
- $perPage : int
- $currentPage : int
- $options : array<string|int, mixed>