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.
Alias for the "pluck" method.
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 236
Model
firstOrCreate(
array $attributes)
Get the first record matching the attributes or create it.
at line line 256
Model
updateOrCreate(
array $attributes,
array $values = array())
Create or update a record matching the attributes, and fill it with values.
at line line 271
Model|Builder|null
first(
array $columns = array('*'))
Execute the query and get the first result.
at line line 284
Model|Builder
firstOrFail(
array $columns = array('*'))
Execute the query and get the first result or throw an exception.
at line line 299
Collection|Builder[]
get(
array $columns = array('*'))
Execute the query as a "select" statement.
at line line 321
mixed
value(
string $column)
Get a single column's value from the first result of a query.
at line line 365
bool
chunkById(
int $count,
callable $callback,
string $column = 'id')
Chunk the results of a query by comparing numeric IDs.
at line line 391
bool
each(
callable $callback,
int $count = 1000)
Execute a callback over each item while chunking.
at line line 413
Collection
pluck(
string $column,
string|null $key = null)
Get an array with the values of a given column.
at line line 440
Collection
lists(
string $column,
string $key = null)
Alias for the "pluck" method.
at line line 456
LengthAwarePaginator
paginate(
int $perPage = null,
array $columns = array('*'),
string $pageName = 'page',
int|null $page = null)
Paginate the given query.
at line line 481
Paginator
simplePaginate(
int $perPage = null,
array $columns = array('*'),
string $pageName = 'page')
Paginate the given query into a simple paginator.
at line line 514
int
increment(
string $column,
int $amount = 1,
array $extra = array())
Increment a column's value by a given amount.
at line line 529
int
decrement(
string $column,
int $amount = 1,
array $extra = array())
Decrement a column's value by a given amount.
at line line 583
void
onDelete(
Closure $callback)
Register a replacement for the default delete function.
at line line 594
Model[]
getModels(
array $columns = array('*'))
Get the hydrated models without eager loading.
at line line 609
array
eagerLoadRelations(
array $models)
Eager load the relationships for the models.
at line line 658
Relation
getRelation(
string $name)
Get the relation instance for the given relation name.
at line line 724
$this
where(
string $column,
string $operator = null,
mixed $value = null,
string $boolean = 'and')
Add a basic where clause to the query.
at line line 747
Builder|Builder
orWhere(
string $column,
string $operator = null,
mixed $value = null)
Add an "or where" clause to the query.
at line line 762
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 823
Builder|Builder
doesntHave(
string $relation,
string $boolean = 'and',
Closure $callback = null)
Add a relationship count / exists condition to the query.
at line line 837
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 849
Builder|Builder
whereDoesntHave(
string $relation,
Closure $callback = null)
Add a relationship count / exists condition to the query with where clauses.
at line line 862
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 876
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 1079
Builder|Builder
applyScopes()
Apply the scopes to the Eloquent builder instance and return it.
at line line 1262
$this
setEagerLoads(
array $eagerLoad)
Set the relationships being eagerly loaded.
at line line 1301
void
macro(
string $name,
Closure $callback)
Extend the builder with a given callback.
at line line 1324
mixed
__call(
string $method,
array $parameters)
Dynamically handle calls into the query instance.