Builder
class Builder (View source)
Traits
Properties
Methods
Dynamically handle calls to the class.
Handle dynamic method calls into the method.
Create a new query builder instance.
Set the columns to be selected.
Add a new "raw" select expression to the query.
Add a new select column to the query.
Force the query to only return distinct results.
Set the table which the query is targeting.
Add a join clause to the query.
Add a "join where" clause to the query.
Add a left join to the query.
Add a "join where" clause to the query.
Add a right join to the query.
Add a "right join where" clause to the query.
Add a "cross join" clause to the query.
Add an "or where" clause to the query.
Add a raw where clause to the query.
Add a raw or where clause to the query.
Add a where between statement to the query.
Add an or where between statement to the query.
Add a where not between statement to the query.
Add an or where not between statement to the query.
Create a new query instance for nested where condition.
Add another query builder as a nested where to the query builder.
Add an exists clause to the query.
Add a where not exists clause to the query.
Add an exists clause to the query.
Add a "where in" clause to the query.
Add a "where not in" clause to the query.
Add an "or where not in" clause to the query.
Add a "where null" clause to the query.
Add an "or where null" clause to the query.
Add a "where not null" clause to the query.
Add an "or where not null" clause to the query.
Add a "where date" statement to the query.
Add an "or where date" statement to the query.
Add a "where day" statement to the query.
Add a "where month" statement to the query.
Add a "where year" statement to the query.
Handles dynamic "where" clauses to the query.
Add a "group by" clause to the query.
Add a "having" clause to the query.
Add a "or having" clause to the query.
Add a raw having clause to the query.
Add a raw or having clause to the query.
Add an "order by" clause to the query.
Add an "order by" clause for a timestamp to the query.
Add an "order by" clause for a timestamp to the query.
Add a raw "order by" clause to the query.
Set the "offset" value of the query.
Set the "limit" value of the query.
Constrain the query to the next "page" of results after a given ID.
Lock the selected rows in the table.
Lock the selected rows in the table for updating.
Share lock the selected rows in the table.
Get the SQL representation of the query.
Execute a query for a single record by ID.
Get a single column's value from the first result of a query.
Execute the query as a "select" statement.
Paginate the given query into a simple paginator.
Get a paginator only supporting simple next and previous links.
Get the count of the total records for the paginator.
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.
Concatenate values of a given column as a string.
Determine if any rows exist for the current query.
Retrieve the "count" result of the query.
Retrieve the minimum value of a given column.
Retrieve the maximum value of a given column.
Retrieve the sum of the values of a given column.
Retrieve the average of the values of a given column.
Alias for the "avg" method.
Execute an aggregate function on the database.
Insert a new record into the database.
Insert a new record and get the value of the primary key.
Update a record in the database.
Insert or update a record matching the attributes, and fill it with values.
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 a truncate statement on the table.
Merge an array of where clauses and bindings.
Create a raw database expression.
Get the current query value bindings in a flattened array.
Get the raw array of bindings.
Set the bindings on the query builder.
Add a binding to the query.
Get the database connection instance.
Get the database query processor instance.
Get the query grammar instance.
Use the write pdo for query.
Details
static
mixed
__callStatic(
string $method,
array $parameters)
Dynamically handle calls to the class.
at line line 2231
mixed
__call(
string $method,
array $parameters)
Handle dynamic method calls into the method.
at line line 215
void
__construct(
ConnectionInterface $connection,
Grammar $grammar = null,
Processor $processor = null)
Create a new query builder instance.
at line line 244
Builder|Builder
selectRaw(
string $expression,
array $bindings = array())
Add a new "raw" select expression to the query.
at line line 264
Builder|Builder
selectSub(
Closure|Builder|string $query,
string $as)
Add a subselect expression to the query.
at line line 336
$this
join(
string $table,
string $one,
string $operator = null,
string $two = null,
string $type = 'inner',
bool $where = false)
Add a join clause to the query.
at line line 377
Builder|Builder
joinWhere(
string $table,
string $one,
string $operator,
string $two,
string $type = 'inner')
Add a "join where" clause to the query.
at line line 391
Builder|Builder
leftJoin(
string $table,
string $first,
string $operator = null,
string $second = null)
Add a left join to the query.
at line line 405
Builder|Builder
leftJoinWhere(
string $table,
string $one,
string $operator,
string $two)
Add a "join where" clause to the query.
at line line 419
Builder|Builder
rightJoin(
string $table,
string $first,
string $operator = null,
string $second = null)
Add a right join to the query.
at line line 433
Builder|Builder
rightJoinWhere(
string $table,
string $one,
string $operator,
string $two)
Add a "right join where" clause to the query.
at line line 447
Builder|Builder
crossJoin(
string $table,
string $first = null,
string $operator = null,
string $second = null)
Add a "cross join" clause to the query.
at line line 465
Builder
when(
bool $value,
Closure $callback)
Apply the callback's query changes if the given "value" is true.
at line line 487
$this
where(
string|array|Closure $column,
string $operator = null,
mixed $value = null,
string $boolean = 'and')
Add a basic where clause to the query.
at line line 576
Builder|Builder
orWhere(
string $column,
string $operator = null,
mixed $value = null)
Add an "or where" clause to the query.
at line line 603
$this
whereRaw(
string $sql,
mixed $bindings = array(),
string $boolean = 'and')
Add a raw where clause to the query.
at line line 623
Builder|Builder
orWhereRaw(
string $sql,
array $bindings = array())
Add a raw or where clause to the query.
at line line 637
$this
whereBetween(
string $column,
array $values,
string $boolean = 'and',
bool $not = false)
Add a where between statement to the query.
at line line 655
Builder|Builder
orWhereBetween(
string $column,
array $values)
Add an or where between statement to the query.
at line line 668
Builder|Builder
whereNotBetween(
string $column,
array $values,
string $boolean = 'and')
Add a where not between statement to the query.
at line line 680
Builder|Builder
orWhereNotBetween(
string $column,
array $values)
Add an or where not between statement to the query.
at line line 692
Builder|Builder
whereNested(
Closure $callback,
string $boolean = 'and')
Add a nested where statement to the query.
at line line 720
$this
addNestedWhereQuery(
Builder|Builder $query,
string $boolean = 'and')
Add another query builder as a nested where to the query builder.
at line line 768
$this
whereExists(
Closure $callback,
string $boolean = 'and',
bool $not = false)
Add an exists clause to the query.
at line line 787
Builder|Builder
orWhereExists(
Closure $callback,
bool $not = false)
Add an or exists clause to the query.
at line line 799
Builder|Builder
whereNotExists(
Closure $callback,
string $boolean = 'and')
Add a where not exists clause to the query.
at line line 810
Builder|Builder
orWhereNotExists(
Closure $callback)
Add a where not exists clause to the query.
at line line 823
$this
addWhereExistsQuery(
Builder $query,
string $boolean = 'and',
bool $not = false)
Add an exists clause to the query.
at line line 843
$this
whereIn(
string $column,
mixed $values,
string $boolean = 'and',
bool $not = false)
Add a "where in" clause to the query.
at line line 878
Builder|Builder
orWhereIn(
string $column,
mixed $values)
Add an "or where in" clause to the query.
at line line 891
Builder|Builder
whereNotIn(
string $column,
mixed $values,
string $boolean = 'and')
Add a "where not in" clause to the query.
at line line 903
Builder|Builder
orWhereNotIn(
string $column,
mixed $values)
Add an "or where not in" clause to the query.
at line line 961
$this
whereNull(
string $column,
string $boolean = 'and',
bool $not = false)
Add a "where null" clause to the query.
at line line 976
Builder|Builder
orWhereNull(
string $column)
Add an "or where null" clause to the query.
at line line 988
Builder|Builder
whereNotNull(
string $column,
string $boolean = 'and')
Add a "where not null" clause to the query.
at line line 999
Builder|Builder
orWhereNotNull(
string $column)
Add an "or where not null" clause to the query.
at line line 1013
Builder|Builder
whereDate(
string $column,
string $operator,
int $value,
string $boolean = 'and')
Add a "where date" statement to the query.
at line line 1026
Builder|Builder
orWhereDate(
string $column,
string $operator,
int $value)
Add an "or where date" statement to the query.
at line line 1040
Builder|Builder
whereDay(
string $column,
string $operator,
int $value,
string $boolean = 'and')
Add a "where day" statement to the query.
at line line 1054
Builder|Builder
whereMonth(
string $column,
string $operator,
int $value,
string $boolean = 'and')
Add a "where month" statement to the query.
at line line 1068
Builder|Builder
whereYear(
string $column,
string $operator,
int $value,
string $boolean = 'and')
Add a "where year" statement to the query.
at line line 1099
$this
dynamicWhere(
string $method,
string $parameters)
Handles dynamic "where" clauses to the query.
at line line 1176
$this
having(
string $column,
string $operator = null,
string $value = null,
string $boolean = 'and')
Add a "having" clause to the query.
at line line 1197
Builder|Builder
orHaving(
string $column,
string $operator = null,
string $value = null)
Add a "or having" clause to the query.
at line line 1210
$this
havingRaw(
string $sql,
array $bindings = array(),
string $boolean = 'and')
Add a raw having clause to the query.
at line line 1228
Builder|Builder
orHavingRaw(
string $sql,
array $bindings = array())
Add a raw or having clause to the query.
at line line 1240
$this
orderBy(
string $column,
string $direction = 'asc')
Add an "order by" clause to the query.
at line line 1256
Builder|Builder
latest(
string $column = 'created_at')
Add an "order by" clause for a timestamp to the query.
at line line 1267
Builder|Builder
oldest(
string $column = 'created_at')
Add an "order by" clause for a timestamp to the query.
at line line 1279
$this
orderByRaw(
string $sql,
array $bindings = array())
Add a raw "order by" clause to the query.
at line line 1353
Builder|Builder
forPage(
int $page,
int $perPage = 15)
Set the limit and offset for a given page.
at line line 1366
Builder|Builder
forPageAfterId(
int $perPage = 15,
int $lastId,
string $column = 'id')
Constrain the query to the next "page" of results after a given ID.
at line line 1380
Builder|Builder
union(
Builder|Closure $query,
bool $all = false)
Add a union statement to the query.
at line line 1399
Builder|Builder
unionAll(
Builder|Closure $query)
Add a union all statement to the query.
at line line 1458
mixed|Builder
find(
int $id,
array $columns = array('*'))
Execute a query for a single record by ID.
at line line 1469
mixed
value(
string $column)
Get a single column's value from the first result of a query.
at line line 1482
stdClass|array|null
first(
array $columns = array('*'))
Execute the query and get the first result.
at line line 1493
Collection
get(
array $columns = array('*'))
Execute the query as a "select" statement.
at line line 1527
LengthAwarePaginator
paginate(
int $perPage = 15,
array $columns = array('*'),
string $pageName = 'page',
int|null $page = null)
Paginate the given query into a simple paginator.
at line line 1551
Paginator
simplePaginate(
int $perPage = 15,
array $columns = array('*'),
string $pageName = 'page')
Get a paginator only supporting simple next and previous links.
This is more efficient on larger data-sets, etc.
at line line 1569
int
getCountForPagination(
array $columns = array('*'))
Get the count of the total records for the paginator.
at line line 1676
bool
chunkById(
int $count,
callable $callback,
string $column = 'id')
Chunk the results of a query by comparing numeric IDs.
at line line 1704
bool
each(
callable $callback,
int $count = 1000)
Execute a callback over each item while chunking.
at line line 1726
Collection
pluck(
string $column,
string|null $key = null)
Get an array with the values of a given column.
at line line 1757
string
implode(
string $column,
string $glue = '')
Concatenate values of a given column as a string.
at line line 1838
float|int
avg(
string $column)
Retrieve the average of the values of a given column.
at line line 1861
float|int
aggregate(
string $function,
array $columns = array('*'))
Execute an aggregate function on the database.
at line line 1949
int
insertGetId(
array $values,
string $sequence = null)
Insert a new record and get the value of the primary key.
at line line 1980
bool
updateOrInsert(
array $attributes,
array $values = array())
Insert or update a record matching the attributes, and fill it with values.
at line line 1997
int
increment(
string $column,
int $amount = 1,
array $extra = array())
Increment a column's value by a given amount.
at line line 2014
int
decrement(
string $column,
int $amount = 1,
array $extra = array())
Decrement a column's value by a given amount.
at line line 2072
void
mergeWheres(
array $wheres,
array $bindings)
Merge an array of where clauses and bindings.
at line line 2132
$this
setBindings(
array $bindings,
string $type = 'where')
Set the bindings on the query builder.
at line line 2152
$this
addBinding(
mixed $value,
string $type = 'where')
Add a binding to the query.