Method |
Description |
|
addBinding ( mixed $value, string $type = 'where' ) |
Add a binding to the query. |
|
addNestedWhereQuery ( Builder | static $query, string $boolean = 'and' ) |
Add another query builder as a nested where to the query builder. |
|
addSelect ( array | mixed $column ) |
Add a new select column to the query. |
|
addWhereExistsQuery ( Builder $query, string $boolean = 'and', boolean $not = false ) |
Add an exists clause to the query. |
|
aggregate ( string $function, array $columns = [] ) : float | integer |
Execute an aggregate function on the database. |
|
applyScopes ( ) : Builder | static |
Apply the scopes to the Eloquent builder instance and return it. |
|
average ( string $column ) : float | integer |
Alias for the "avg" method. |
|
avg ( string $column ) : float | integer |
Retrieve the average of the values of a given column. |
|
chunk ( integer $count, callable $callback ) : boolean |
Chunk the results of the query. |
|
chunkById ( integer $count, callable $callback, string $column = 'id' ) : boolean |
Chunk the results of a query by comparing numeric IDs. |
|
count ( string $columns = '*' ) : integer |
Retrieve the "count" result of the query. |
|
crossJoin ( string $table, string $first = null, string $operator = null, string $second = null ) : Builder | static |
Add a "cross join" clause to the query. |
|
cursor ( ) : Generator |
Get a generator for the given query. |
|
distinct ( ) |
Force the query to only return distinct results. |
|
doesntHave ( string $relation, string $boolean = 'and', Closure | null $callback = null ) : Builder | static |
Add a relationship count / exists condition to the query. |
|
dynamicWhere ( string $method, string $parameters ) |
Handles dynamic "where" clauses to the query. |
|
each ( callable $callback, integer $count = 1000 ) : boolean |
Execute a callback over each item while chunking. |
|
eagerLoadRelations ( array $models ) : array |
Eager load the relationships for the models. |
|
exists ( ) : boolean |
Determine if any rows exist for the current query. |
|
find ( mixed $id, array $columns = [] ) : Model | Illuminate\Database\Eloquent\Collection | static[] | static | null |
Find a model by its primary key. |
|
findMany ( array $ids, array $columns = [] ) : Illuminate\Database\Eloquent\Collection |
Find multiple models by their primary keys. |
|
findOrFail ( mixed $id, array $columns = [] ) : Model | Illuminate\Database\Eloquent\Collection |
Find a model by its primary key or throw an exception. |
|
findOrNew ( mixed $id, array $columns = [] ) : Model |
Find a model by its primary key or return fresh model instance. |
|
first ( array $columns = [] ) : Model | static | null |
Execute the query and get the first result. |
|
firstOrCreate ( array $attributes ) : Model |
Get the first record matching the attributes or create it. |
|
firstOrFail ( array $columns = [] ) : Model | static |
Execute the query and get the first result or throw an exception. |
|
firstOrNew ( array $attributes ) : Model |
Get the first record matching the attributes or instantiate it. |
|
forNestedWhere ( ) : Builder |
Create a new query instance for nested where condition. |
|
forPage ( integer $page, integer $perPage = 15 ) : Builder | static |
Set the limit and offset for a given page. |
|
forPageAfterId ( integer $perPage = 15, integer $lastId, string $column = 'id' ) : Builder | static |
Constrain the query to the next "page" of results after a given ID. |
|
from ( string $table ) |
Set the table which the query is targeting. |
|
get ( array $columns = [] ) : Illuminate\Database\Eloquent\Collection | static[] |
Execute the query as a "select" statement. |
|
getBindings ( ) : array |
Get the current query value bindings in a flattened array. |
|
getCountForPagination ( array $columns = [] ) : integer |
Get the count of the total records for the paginator. |
|
getEagerLoads ( ) : array |
Get the relationships being eagerly loaded. |
|
getGrammar ( ) : Illuminate\Database\Query\Grammars\Grammar |
Get the query grammar instance. |
|
getMacro ( string $name ) : Closure |
Get the given macro by name. |
|
getModel ( ) : Model |
Get the model instance being queried. |
|
getModels ( array $columns = [] ) : Model[] |
Get the hydrated models without eager loading. |
|
getProcessor ( ) : Illuminate\Database\Query\Processors\Processor |
Get the database query processor instance. |
|
getQuery ( ) : Builder |
Get the underlying query builder instance. |
|
getRawBindings ( ) : array |
Get the raw array of bindings. |
|
groupBy ( ) |
Add a "group by" clause to the query. |
|
has ( string $relation, string $operator = '>=', integer $count = 1, string $boolean = 'and', Closure | null $callback = null ) : Builder | static |
Add a relationship count / exists condition to the query. |
|
hasMacro ( string $name ) : boolean |
Checks if macro is registered. |
|
having ( string $column, string $operator = null, string $value = null, string $boolean = 'and' ) |
Add a "having" clause to the query. |
|
havingRaw ( string $sql, array $bindings = [], string $boolean = 'and' ) |
Add a raw having clause to the query. |
|
implode ( string $column, string $glue = '' ) : string |
Concatenate values of a given column as a string. |
|
inRandomOrder ( string $seed = '' ) |
Put the query's results in random order. |
|
insert ( array $values ) : boolean |
Insert a new record into the database. |
|
insertGetId ( array $values, string $sequence = null ) : integer |
Insert a new record and get the value of the primary key. |
|
join ( string $table, string $one, string $operator = null, string $two = null, string $type = 'inner', boolean $where = false ) |
Add a join clause to the query. |
|
joinWhere ( string $table, string $one, string $operator, string $two, string $type = 'inner' ) : Builder | static |
Add a "join where" clause to the query. |
|
latest ( string $column = 'created_at' ) : Builder | static |
Add an "order by" clause for a timestamp to the query. |
|
leftJoin ( string $table, string $first, string $operator = null, string $second = null ) : Builder | static |
Add a left join to the query. |
|
leftJoinWhere ( string $table, string $one, string $operator, string $two ) : Builder | static |
Add a "join where" clause to the query. |
|
limit ( integer $value ) |
Set the "limit" value of the query. |
|
lists ( string $column, string $key = null ) : Collection |
Alias for the "pluck" method. |
|
lock ( boolean $value = true ) |
Lock the selected rows in the table. |
|
lockForUpdate ( ) : Builder |
Lock the selected rows in the table for updating. |
|
macro ( string $name, Closure $callback ) : void |
Extend the builder with a given callback. |
|
macroCall ( string $method, array $parameters ) : mixed |
Dynamically handle calls to the class. |
|
max ( string $column ) : float | integer |
Retrieve the maximum value of a given column. |
|
mergeBindings ( Builder $query ) |
Merge an array of bindings into our bindings. |
|
mergeModelDefinedRelationConstraints ( Builder $relation ) : Builder | static |
Merge the constraints from a relation query to the current query. |
|
mergeWheres ( array $wheres, array $bindings ) : void |
Merge an array of where clauses and bindings. |
|
min ( string $column ) : float | integer |
Retrieve the minimum value of a given column. |
|
offset ( integer $value ) |
Set the "offset" value of the query. |
|
oldest ( string $column = 'created_at' ) : Builder | static |
Add an "order by" clause for a timestamp to the query. |
|
onDelete ( Closure $callback ) : void |
Register a replacement for the default delete function. |
|
orHas ( string $relation, string $operator = '>=', integer $count = 1 ) : Builder | static |
Add a relationship count / exists condition to the query with an "or". |
|
orHaving ( string $column, string $operator = null, string $value = null ) : Builder | static |
Add a "or having" clause to the query. |
|
orHavingRaw ( string $sql, array $bindings = [] ) : Builder | static |
Add a raw or having clause to the query. |
|
orWhere ( string $column, string $operator = null, mixed $value = null ) : Builder | static |
Add an "or where" clause to the query. |
|
orWhereBetween ( string $column, array $values ) : Builder | static |
Add an or where between statement to the query. |
|
orWhereColumn ( string | array $first, string | null $operator = null, string | null $second = null ) : Builder | static |
Add an "or where" clause comparing two columns to the query. |
|
orWhereDate ( string $column, string $operator, integer $value ) : Builder | static |
Add an "or where date" statement to the query. |
|
orWhereExists ( Closure $callback, boolean $not = false ) : Builder | static |
Add an or exists clause to the query. |
|
orWhereHas ( string $relation, Closure $callback, string $operator = '>=', integer $count = 1 ) : Builder | static |
Add a relationship count / exists condition to the query with where clauses and an "or". |
|
orWhereIn ( string $column, mixed $values ) : Builder | static |
Add an "or where in" clause to the query. |
|
orWhereNotBetween ( string $column, array $values ) : Builder | static |
Add an or where not between statement to the query. |
|
orWhereNotExists ( Closure $callback ) : Builder | static |
Add a where not exists clause to the query. |
|
orWhereNotIn ( string $column, mixed $values ) : Builder | static |
Add an "or where not in" clause to the query. |
|
orWhereNotNull ( string $column ) : Builder | static |
Add an "or where not null" clause to the query. |
|
orWhereNull ( string $column ) : Builder | static |
Add an "or where null" clause to the query. |
|
orWhereRaw ( string $sql, array $bindings = [] ) : Builder | static |
Add a raw or where clause to the query. |
|
orWhereTime ( string $column, string $operator, integer $value ) : Builder | static |
Add an "or where time" statement to the query. |
|
orderBy ( string $column, string $direction = 'asc' ) |
Add an "order by" clause to the query. |
|
orderByRaw ( string $sql, array $bindings = [] ) |
Add a raw "order by" clause to the query. |
|
paginate ( integer $perPage = null, array $columns = [], string $pageName = 'page', integer | null $page = null ) : Illuminate\Contracts\Pagination\LengthAwarePaginator |
Paginate the given query. |
|
pluck ( string $column, string | null $key = null ) : Collection |
Get an array with the values of a given column. |
|
raw ( mixed $value ) : Illuminate\Database\Query\Expression |
Create a raw database expression. |
|
removedScopes ( ) : array |
Get an array of global scopes that were removed from the query. |
|
rightJoin ( string $table, string $first, string $operator = null, string $second = null ) : Builder | static |
Add a right join to the query. |
|
rightJoinWhere ( string $table, string $one, string $operator, string $two ) : Builder | static |
Add a "right join where" clause to the query. |
|
scopes ( array $scopes ) : mixed |
Add the given scopes to the current builder instance. |
|
select ( array | mixed $columns = [] ) |
Set the columns to be selected. |
|
selectRaw ( string $expression, array $bindings = [] ) : Builder | static |
Add a new "raw" select expression to the query. |
|
selectSub ( Closure | Builder | string $query, string $as ) : Builder | static |
Add a subselect expression to the query. |
|
setBindings ( array $bindings, string $type = 'where' ) |
Set the bindings on the query builder. |
|
setEagerLoads ( array $eagerLoad ) |
Set the relationships being eagerly loaded. |
|
setModel ( Model $model ) |
Set a model instance for the model being queried. |
|
setQuery ( Builder $query ) |
Set the underlying query builder instance. |
|
sharedLock ( ) : Builder |
Share lock the selected rows in the table. |
|
simplePaginate ( integer $perPage = null, array $columns = [], string $pageName = 'page', integer | null $page = null ) : Illuminate\Contracts\Pagination\Paginator |
Paginate the given query into a simple paginator. |
|
skip ( integer $value ) : Builder | static |
Alias to set the "offset" value of the query. |
|
sum ( string $column ) : float | integer |
Retrieve the sum of the values of a given column. |
|
take ( integer $value ) : Builder | static |
Alias to set the "limit" value of the query. |
|
toBase ( ) : Builder |
Get a base query builder instance. |
|
toSql ( ) : string |
Get the SQL representation of the query. |
|
truncate ( ) : void |
Run a truncate statement on the table. |
|
union ( Builder | Closure $query, boolean $all = false ) : Builder | static |
Add a union statement to the query. |
|
unionAll ( Builder | Closure $query ) : Builder | static |
Add a union all statement to the query. |
|
updateOrCreate ( array $attributes, array $values = [] ) : Model |
Create or update a record matching the attributes, and fill it with values. |
|
updateOrInsert ( array $attributes, array $values = [] ) : boolean |
Insert or update a record matching the attributes, and fill it with values. |
|
useWritePdo ( ) |
Use the write pdo for query. |
|
value ( string $column ) : mixed |
Get a single column's value from the first result of a query. |
|
when ( boolean $value, Closure $callback ) |
Apply the callback's query changes if the given "value" is true. |
|
where ( string $column, string $operator = null, mixed $value = null, string $boolean = 'and' ) |
Add a basic where clause to the query. |
|
whereBetween ( string $column, array $values, string $boolean = 'and', boolean $not = false ) |
Add a where between statement to the query. |
|
whereColumn ( string | array $first, string | null $operator = null, string | null $second = null, string | null $boolean = 'and' ) : Builder | static |
Add a "where" clause comparing two columns to the query. |
|
whereDate ( string $column, string $operator, integer $value, string $boolean = 'and' ) : Builder | static |
Add a "where date" statement to the query. |
|
whereDay ( string $column, string $operator, integer $value, string $boolean = 'and' ) : Builder | static |
Add a "where day" statement to the query. |
|
whereDoesntHave ( string $relation, Closure | null $callback = null ) : Builder | static |
Add a relationship count / exists condition to the query with where clauses. |
|
whereExists ( Closure $callback, string $boolean = 'and', boolean $not = false ) |
Add an exists clause to the query. |
|
whereHas ( string $relation, Closure $callback, string $operator = '>=', integer $count = 1 ) : Builder | static |
Add a relationship count / exists condition to the query with where clauses. |
|
whereIn ( string $column, mixed $values, string $boolean = 'and', boolean $not = false ) |
Add a "where in" clause to the query. |
|
whereMonth ( string $column, string $operator, integer $value, string $boolean = 'and' ) : Builder | static |
Add a "where month" statement to the query. |
|
whereNested ( Closure $callback, string $boolean = 'and' ) : Builder | static |
Add a nested where statement to the query. |
|
whereNotBetween ( string $column, array $values, string $boolean = 'and' ) : Builder | static |
Add a where not between statement to the query. |
|
whereNotExists ( Closure $callback, string $boolean = 'and' ) : Builder | static |
Add a where not exists clause to the query. |
|
whereNotIn ( string $column, mixed $values, string $boolean = 'and' ) : Builder | static |
Add a "where not in" clause to the query. |
|
whereNotNull ( string $column, string $boolean = 'and' ) : Builder | static |
Add a "where not null" clause to the query. |
|
whereNull ( string $column, string $boolean = 'and', boolean $not = false ) |
Add a "where null" clause to the query. |
|
whereRaw ( string $sql, array $bindings = [], string $boolean = 'and' ) |
Add a raw where clause to the query. |
|
whereTime ( string $column, string $operator, integer $value, string $boolean = 'and' ) : Builder | static |
Add a "where time" statement to the query. |
|
whereYear ( string $column, string $operator, integer $value, string $boolean = 'and' ) : Builder | static |
Add a "where year" statement to the query. |
|
withCount ( mixed $relations ) |
Add subselect queries to count the relations. |
|
withGlobalScope ( string $identifier, Illuminate\Database\Eloquent\Scope | Closure $scope ) |
Register a new global scope. |
|
without ( mixed $relations ) |
Prevent the specified relations from being eager loaded. |
|
withoutGlobalScope ( Illuminate\Database\Eloquent\Scope | string $scope ) |
Remove a registered global scope. |
|
withoutGlobalScopes ( array | null $scopes = null ) |
Remove all or passed registered global scopes. |
|