Builder
class Builder (View source)
Methods
Remove all or passed registered global scopes.
Find a model by its primary key.
Find multiple models by their primary keys.
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 or create it.
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.
Execute the query as a "select" statement.
Get a single column's value from the first result of a query.
Chunk the results of the query.
Chunk the results of a query by comparing numeric IDs.
Execute a callback over each item while chunking.
Get an array with the values of a given column.
Paginate the given query.
Paginate the given query into a simple paginator.
Update a record in the database.
Increment a column's value by a given amount.
Decrement a column's value by a given amount.
Delete a record from the database.
Run the default delete function on the builder.
Eager load the relationships for the models.
Get the relation instance for the given relation name.
Add a basic where clause to the query.
Add an "or where" clause to the query.
Add a relationship count / exists condition to the query.
Add a relationship count / exists condition to the query with where clauses.
Add a relationship count / exists condition to the query with an "or".
Add a relationship count / exists condition to the query with where clauses and an "or".
Set the relationships that should be eager loaded.
Apply the scopes to the Eloquent builder instance and return it.
Get the relationships being eagerly loaded.
Set the relationships being eagerly loaded.
Dynamically handle calls into the query instance.
Force a clone of the underlying query builder when cloning.
Details
at line line 86
$this
withGlobalScope(
string $identifier,
Scope|Closure $scope)
Register a new global scope.
at line line 126
$this
withoutGlobalScopes(
array $scopes = null)
Remove all or passed registered global scopes.
at line line 146
Model|Collection|Builder[]|Builder|null
find(
mixed $id,
array $columns = array('*'))
Find a model by its primary key.
at line line 164
Collection
findMany(
array $ids,
array $columns = array('*'))
Find multiple models by their primary keys.
at line line 184
Model|Collection
findOrFail(
mixed $id,
array $columns = array('*'))
Find a model by its primary key or throw an exception.
at line line 206
Model
findOrNew(
mixed $id,
array $columns = array('*'))
Find a model by its primary key or return fresh model instance.
at line line 221
Model
firstOrNew(
array $attributes)
Get the first record matching the attributes or instantiate it.
at line line 237
Model
firstOrCreate(
array $attributes,
array $values = array())
Get the first record matching the attributes or create it.
at line line 257
Model
updateOrCreate(
array $attributes,
array $values = array())
Create or update a record matching the attributes, and fill it with values.
at line line 272
Model|Builder|null
first(
array $columns = array('*'))
Execute the query and get the first result.
at line line 285
Model|Builder
firstOrFail(
array $columns = array('*'))
Execute the query and get the first result or throw an exception.
at line line 300
Collection|Builder[]
get(
array $columns = array('*'))
Execute the query as a "select" statement.
at line line 322
mixed
value(
string $column)
Get a single column's value from the first result of a query.
at line line 366
bool
chunkById(
int $count,
callable $callback,
string $column = 'id')
Chunk the results of a query by comparing numeric IDs.
at line line 392
bool
each(
callable $callback,
int $count = 1000)
Execute a callback over each item while chunking.
at line line 414
Collection
pluck(
string $column,
string|null $key = null)
Get an array with the values of a given column.
at line line 441
LengthAwarePaginator
paginate(
int $perPage = null,
array $columns = array('*'),
string $pageName = 'page',
int|null $page = null)
Paginate the given query.
at line line 466
Paginator
simplePaginate(
int $perPage = null,
array $columns = array('*'),
string $pageName = 'page')
Paginate the given query into a simple paginator.
at line line 499
int
increment(
string $column,
int $amount = 1,
array $extra = array())
Increment a column's value by a given amount.
at line line 514
int
decrement(
string $column,
int $amount = 1,
array $extra = array())
Decrement a column's value by a given amount.
at line line 568
void
onDelete(
Closure $callback)
Register a replacement for the default delete function.
at line line 579
Model[]
getModels(
array $columns = array('*'))
Get the hydrated models without eager loading.
at line line 594
array
eagerLoadRelations(
array $models)
Eager load the relationships for the models.
at line line 643
Relation
getRelation(
string $name)
Get the relation instance for the given relation name.
at line line 709
$this
where(
string $column,
string $operator = null,
mixed $value = null,
string $boolean = 'and')
Add a basic where clause to the query.
at line line 732
Builder|Builder
orWhere(
string $column,
string $operator = null,
mixed $value = null)
Add an "or where" clause to the query.
at line line 747
Builder|Builder
has(
string $relation,
string $operator = '>=',
int $count = 1,
string $boolean = 'and',
Closure $callback = null)
Add a relationship count / exists condition to the query.
at line line 808
Builder|Builder
doesntHave(
string $relation,
string $boolean = 'and',
Closure $callback = null)
Add a relationship count / exists condition to the query.
at line line 822
Builder|Builder
whereHas(
string $relation,
Closure $callback,
string $operator = '>=',
int $count = 1)
Add a relationship count / exists condition to the query with where clauses.
at line line 834
Builder|Builder
whereDoesntHave(
string $relation,
Closure $callback = null)
Add a relationship count / exists condition to the query with where clauses.
at line line 847
Builder|Builder
orHas(
string $relation,
string $operator = '>=',
int $count = 1)
Add a relationship count / exists condition to the query with an "or".
at line line 861
Builder|Builder
orWhereHas(
string $relation,
Closure $callback,
string $operator = '>=',
int $count = 1)
Add a relationship count / exists condition to the query with where clauses and an "or".
at line line 1064
Builder|Builder
applyScopes()
Apply the scopes to the Eloquent builder instance and return it.
at line line 1248
$this
setEagerLoads(
array $eagerLoad)
Set the relationships being eagerly loaded.
at line line 1287
void
macro(
string $name,
Closure $callback)
Extend the builder with a given callback.
at line line 1310
mixed
__call(
string $method,
array $parameters)
Dynamically handle calls into the query instance.