Documentation

JoinClause extends Builder
in package

Table of Contents

$aggregate  : array<string|int, mixed>
An aggregate function and column to be run.
$bindings  : array<string|int, mixed>
The current query value bindings.
$columns  : array<string|int, mixed>
The columns that should be returned.
$connection  : ConnectionInterface
The database connection instance.
$distinct  : bool
Indicates if the query returns distinct results.
$from  : string
The table which the query is targeting.
$grammar  : Grammar
The database query grammar instance.
$groups  : array<string|int, mixed>
The groupings for the query.
$havings  : array<string|int, mixed>
The having constraints for the query.
$joins  : array<string|int, mixed>
The table joins for the query.
$limit  : int
The maximum number of records to return.
$lock  : string|bool
Indicates whether row locking is being used.
$offset  : int
The number of records to skip.
$operators  : array<string|int, mixed>
All of the available clause operators.
$orders  : array<string|int, mixed>
The orderings for the query.
$processor  : Processor
The database query post processor instance.
$table  : string
The table the join clause is joining to.
$type  : string
The type of join being performed.
$unionLimit  : int
The maximum number of union records to return.
$unionOffset  : int
The number of union records to skip.
$unionOrders  : array<string|int, mixed>
The orderings for the union query.
$unions  : array<string|int, mixed>
The query union statements.
$useWritePdo  : bool
Whether use write pdo for select.
$wheres  : array<string|int, mixed>
The where constraints for the query.
$macros  : array<string|int, mixed>
The registered string macros.
$parentQuery  : Builder
The parent query builder instance.
__call()  : mixed
Dynamically handle calls to the class.
__callStatic()  : mixed
Dynamically handle calls to the class.
__construct()  : void
Create a new join clause instance.
addBinding()  : $this
Add a binding to the query.
addNestedWhereQuery()  : $this
Add another query builder as a nested where to the query builder.
addSelect()  : $this
Add a new select column to the query.
addWhereExistsQuery()  : $this
Add an exists clause to the query.
aggregate()  : mixed
Execute an aggregate function on the database.
average()  : mixed
Alias for the "avg" method.
avg()  : mixed
Retrieve the average of the values of a given column.
chunk()  : bool
Chunk the results of the query.
chunkById()  : bool
Chunk the results of a query by comparing numeric IDs.
cloneWithout()  : static
Clone the query without the given properties.
cloneWithoutBindings()  : static
Clone the query without the given bindings.
count()  : int
Retrieve the "count" result of the query.
crossJoin()  : Builder|static
Add a "cross join" clause to the query.
cursor()  : Generator
Get a generator for the given query.
decrement()  : int
Decrement a column's value by a given amount.
delete()  : int
Delete a record from the database.
distinct()  : $this
Force the query to only return distinct results.
doesntExist()  : bool
Determine if no rows exist for the current query.
dynamicWhere()  : $this
Handles dynamic "where" clauses to the query.
each()  : bool
Execute a callback over each item while chunking.
exists()  : bool
Determine if any rows exist for the current query.
find()  : mixed|static
Execute a query for a single record by ID.
first()  : Model|object|static|null
Execute the query and get the first result.
forNestedWhere()  : Builder
Create a new query instance for nested where condition.
forPage()  : Builder|static
Set the limit and offset for a given page.
forPageAfterId()  : Builder|static
Constrain the query to the next "page" of results after a given ID.
from()  : $this
Set the table which the query is targeting.
get()  : Collection
Execute the query as a "select" statement.
getBindings()  : array<string|int, mixed>
Get the current query value bindings in a flattened array.
getConnection()  : ConnectionInterface
Get the database connection instance.
getCountForPagination()  : int
Get the count of the total records for the paginator.
getGrammar()  : Grammar
Get the query grammar instance.
getProcessor()  : Processor
Get the database query processor instance.
getRawBindings()  : array<string|int, mixed>
Get the raw array of bindings.
groupBy()  : $this
Add a "group by" clause to the query.
hasMacro()  : bool
Checks if macro is registered.
having()  : $this
Add a "having" clause to the query.
havingRaw()  : $this
Add a raw having clause to the query.
implode()  : string
Concatenate values of a given column as a string.
increment()  : int
Increment a column's value by a given amount.
inRandomOrder()  : $this
Put the query's results in random order.
insert()  : bool
Insert a new record into the database.
insertGetId()  : int
Insert a new record and get the value of the primary key.
join()  : $this
Add a join clause to the query.
joinWhere()  : Builder|static
Add a "join where" clause to the query.
latest()  : Builder|static
Add an "order by" clause for a timestamp to the query.
leftJoin()  : Builder|static
Add a left join to the query.
leftJoinWhere()  : Builder|static
Add a "join where" clause to the query.
limit()  : $this
Set the "limit" value of the query.
lock()  : $this
Lock the selected rows in the table.
lockForUpdate()  : Builder
Lock the selected rows in the table for updating.
macro()  : void
Register a custom macro.
max()  : mixed
Retrieve the maximum value of a given column.
mergeBindings()  : $this
Merge an array of bindings into our bindings.
mergeWheres()  : void
Merge an array of where clauses and bindings.
min()  : mixed
Retrieve the minimum value of a given column.
mixin()  : void
Mix another object into the class.
newQuery()  : JoinClause
Get a new instance of the join clause builder.
numericAggregate()  : float|int
Execute a numeric aggregate function on the database.
offset()  : $this
Set the "offset" value of the query.
oldest()  : Builder|static
Add an "order by" clause for a timestamp to the query.
on()  : $this
Add an "on" clause to the join.
orderBy()  : $this
Add an "order by" clause to the query.
orderByDesc()  : $this
Add a descending "order by" clause to the query.
orderByRaw()  : $this
Add a raw "order by" clause to the query.
orHaving()  : Builder|static
Add a "or having" clause to the query.
orHavingRaw()  : Builder|static
Add a raw or having clause to the query.
orOn()  : JoinClause
Add an "or on" clause to the join.
orWhere()  : Builder|static
Add an "or where" clause to the query.
orWhereBetween()  : Builder|static
Add an or where between statement to the query.
orWhereColumn()  : Builder|static
Add an "or where" clause comparing two columns to the query.
orWhereDate()  : Builder|static
Add an "or where date" statement to the query.
orWhereExists()  : Builder|static
Add an or exists clause to the query.
orWhereIn()  : Builder|static
Add an "or where in" clause to the query.
orWhereNotBetween()  : Builder|static
Add an or where not between statement to the query.
orWhereNotExists()  : Builder|static
Add a where not exists clause to the query.
orWhereNotIn()  : Builder|static
Add an "or where not in" clause to the query.
orWhereNotNull()  : Builder|static
Add an "or where not null" clause to the query.
orWhereNull()  : Builder|static
Add an "or where null" clause to the query.
orWhereRaw()  : Builder|static
Add a raw or where clause to the query.
orWhereTime()  : Builder|static
Add an "or where time" statement to the query.
paginate()  : LengthAwarePaginator
Paginate the given query into a simple paginator.
pluck()  : Collection
Get an array with the values of a given column.
prepareValueAndOperator()  : array<string|int, mixed>
Prepare the value and operator for a where clause.
raw()  : Expression
Create a raw database expression.
rightJoin()  : Builder|static
Add a right join to the query.
rightJoinWhere()  : Builder|static
Add a "right join where" clause to the query.
select()  : $this
Set the columns to be selected.
selectRaw()  : Builder|static
Add a new "raw" select expression to the query.
selectSub()  : Builder|static
Add a subselect expression to the query.
setBindings()  : $this
Set the bindings on the query builder.
sharedLock()  : Builder
Share lock the selected rows in the table.
simplePaginate()  : Paginator
Get a paginator only supporting simple next and previous links.
skip()  : Builder|static
Alias to set the "offset" value of the query.
sum()  : mixed
Retrieve the sum of the values of a given column.
take()  : Builder|static
Alias to set the "limit" value of the query.
tap()  : Builder
Pass the query to a given callback.
toSql()  : string
Get the SQL representation of the query.
truncate()  : void
Run a truncate statement on the table.
union()  : Builder|static
Add a union statement to the query.
unionAll()  : Builder|static
Add a union all statement to the query.
unless()  : mixed
Apply the callback's query changes if the given "value" is false.
update()  : int
Update a record in the database.
updateOrInsert()  : bool
Insert or update a record matching the attributes, and fill it with values.
useWritePdo()  : $this
Use the write pdo for query.
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.
whereBetween()  : $this
Add a where between statement to the query.
whereColumn()  : Builder|static
Add a "where" clause comparing two columns to the query.
whereDate()  : Builder|static
Add a "where date" statement to the query.
whereDay()  : Builder|static
Add a "where day" statement to the query.
whereExists()  : $this
Add an exists clause to the query.
whereIn()  : $this
Add a "where in" clause to the query.
whereMonth()  : Builder|static
Add a "where month" statement to the query.
whereNested()  : Builder|static
Add a nested where statement to the query.
whereNotBetween()  : Builder|static
Add a where not between statement to the query.
whereNotExists()  : Builder|static
Add a where not exists clause to the query.
whereNotIn()  : Builder|static
Add a "where not in" clause to the query.
whereNotNull()  : Builder|static
Add a "where not null" clause to the query.
whereNull()  : $this
Add a "where null" clause to the query.
whereRaw()  : $this
Add a raw where clause to the query.
whereTime()  : Builder|static
Add a "where time" statement to the query.
whereYear()  : Builder|static
Add a "where year" statement to the query.
addArrayOfWheres()  : $this
Add an array of where clauses to the query.
addDateBasedWhere()  : $this
Add a date based (year, month, day, time) statement to the query.
addDynamic()  : void
Add a single dynamic where clause statement to the query.
cleanBindings()  : array<string|int, mixed>
Remove all of the expressions from a list of bindings.
enforceOrderBy()  : void
Throw an exception if the query doesn't have an orderBy clause.
forSubQuery()  : Builder
Create a new query instance for sub-query.
invalidOperator()  : bool
Determine if the given operator is supported.
invalidOperatorAndValue()  : bool
Determine if the given operator and value combination is legal.
paginator()  : LengthAwarePaginator
Create a new length-aware paginator instance.
parseSubSelect()  : array<string|int, mixed>
Parse the sub-select query into SQL and bindings.
removeExistingOrdersFor()  : array<string|int, mixed>
Get an array with all orders with a given column removed.
runPaginationCountQuery()  : array<string|int, mixed>
Run a pagination count query.
runSelect()  : array<string|int, mixed>
Run the query as a "select" statement against the connection.
setAggregate()  : $this
Set the aggregate property without running the query.
simplePaginator()  : Paginator
Create a new simple paginator instance.
stripTableForPluck()  : string|null
Strip off the table name or alias from a column identifier.
whereInExistingQuery()  : $this
Add an external sub-select to the query.
whereInSub()  : $this
Add a where in with a sub-select to the query.
whereSub()  : $this
Add a full sub-select to the query.
withoutSelectAliases()  : array<string|int, mixed>
Remove the column aliases since they will break count queries.

Properties

$aggregate

An aggregate function and column to be run.

public array<string|int, mixed> $aggregate

$bindings

The current query value bindings.

public array<string|int, mixed> $bindings = ['select' => [], 'join' => [], 'where' => [], 'having' => [], 'order' => [], 'union' => []]

$columns

The columns that should be returned.

public array<string|int, mixed> $columns

$distinct

Indicates if the query returns distinct results.

public bool $distinct = false

$from

The table which the query is targeting.

public string $from

$groups

The groupings for the query.

public array<string|int, mixed> $groups

$havings

The having constraints for the query.

public array<string|int, mixed> $havings

$joins

The table joins for the query.

public array<string|int, mixed> $joins

$limit

The maximum number of records to return.

public int $limit

$lock

Indicates whether row locking is being used.

public string|bool $lock

$offset

The number of records to skip.

public int $offset

$operators

All of the available clause operators.

public array<string|int, mixed> $operators = ['=', '<', '>', '<=', '>=', '<>', '!=', '<=>', 'like', 'like binary', 'not like', 'ilike', '&', '|', '^', '<<', '>>', 'rlike', 'regexp', 'not regexp', '~', '~*', '!~', '!~*', 'similar to', 'not similar to', 'not ilike', '~~*', '!~~*']

$orders

The orderings for the query.

public array<string|int, mixed> $orders

$processor

The database query post processor instance.

public Processor $processor

$table

The table the join clause is joining to.

public string $table

$type

The type of join being performed.

public string $type

$unionLimit

The maximum number of union records to return.

public int $unionLimit

$unionOffset

The number of union records to skip.

public int $unionOffset

$unionOrders

The orderings for the union query.

public array<string|int, mixed> $unionOrders

$unions

The query union statements.

public array<string|int, mixed> $unions

$useWritePdo

Whether use write pdo for select.

public bool $useWritePdo = false

$wheres

The where constraints for the query.

public array<string|int, mixed> $wheres = []

$macros

The registered string macros.

protected static array<string|int, mixed> $macros = []

Methods

__call()

Dynamically handle calls to the class.

public __call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Tags
throws
BadMethodCallException
Return values
mixed

__callStatic()

Dynamically handle calls to the class.

public static __callStatic(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Tags
throws
BadMethodCallException
Return values
mixed

__construct()

Create a new join clause instance.

public __construct(Builder $parentQuery, string $type, string $table) : void
Parameters
$parentQuery : Builder
$type : string
$table : string
Return values
void

addBinding()

Add a binding to the query.

public addBinding(mixed $value[, string $type = 'where' ]) : $this
Parameters
$value : mixed
$type : string = 'where'
Tags
throws
InvalidArgumentException
Return values
$this

addNestedWhereQuery()

Add another query builder as a nested where to the query builder.

public addNestedWhereQuery(Builder|static $query[, string $boolean = 'and' ]) : $this
Parameters
$query : Builder|static
$boolean : string = 'and'
Return values
$this

addSelect()

Add a new select column to the query.

public addSelect(array<string|int, mixed>|mixed $column) : $this
Parameters
$column : array<string|int, mixed>|mixed
Return values
$this

addWhereExistsQuery()

Add an exists clause to the query.

public addWhereExistsQuery(Builder $query[, string $boolean = 'and' ][, bool $not = false ]) : $this
Parameters
$query : Builder
$boolean : string = 'and'
$not : bool = false
Return values
$this

aggregate()

Execute an aggregate function on the database.

public aggregate(string $function[, array<string|int, mixed> $columns = ['*'] ]) : mixed
Parameters
$function : string
$columns : array<string|int, mixed> = ['*']
Return values
mixed

average()

Alias for the "avg" method.

public average(string $column) : mixed
Parameters
$column : string
Return values
mixed

avg()

Retrieve the average of the values of a given column.

public avg(string $column) : mixed
Parameters
$column : string
Return values
mixed

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 = 'id' ][, string $alias = null ]) : bool
Parameters
$count : int
$callback : callable
$column : string = 'id'
$alias : string = null
Return values
bool

cloneWithout()

Clone the query without the given properties.

public cloneWithout(array<string|int, mixed> $properties) : static
Parameters
$properties : array<string|int, mixed>
Return values
static

cloneWithoutBindings()

Clone the query without the given bindings.

public cloneWithoutBindings(array<string|int, mixed> $except) : static
Parameters
$except : array<string|int, mixed>
Return values
static

count()

Retrieve the "count" result of the query.

public count([string $columns = '*' ]) : int
Parameters
$columns : string = '*'
Return values
int

crossJoin()

Add a "cross join" clause to the query.

public crossJoin(string $table[, string|null $first = null ][, string|null $operator = null ][, string|null $second = null ]) : Builder|static
Parameters
$table : string
$first : string|null = null
$operator : string|null = null
$second : string|null = null
Return values
Builder|static

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 $id = null ]) : int
Parameters
$id : mixed = null
Return values
int

distinct()

Force the query to only return distinct results.

public distinct() : $this
Return values
$this

doesntExist()

Determine if no rows exist for the current query.

public doesntExist() : bool
Return values
bool

dynamicWhere()

Handles dynamic "where" clauses to the query.

public dynamicWhere(string $method, string $parameters) : $this
Parameters
$method : string
$parameters : string
Return values
$this

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

exists()

Determine if any rows exist for the current query.

public exists() : bool
Return values
bool

find()

Execute a query for a single record by ID.

public find(int $id[, array<string|int, mixed> $columns = ['*'] ]) : mixed|static
Parameters
$id : int
$columns : array<string|int, mixed> = ['*']
Return values
mixed|static

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

forNestedWhere()

Create a new query instance for nested where condition.

public forNestedWhere() : Builder
Return values
Builder

forPage()

Set the limit and offset for a given page.

public forPage(int $page[, int $perPage = 15 ]) : Builder|static
Parameters
$page : int
$perPage : int = 15
Return values
Builder|static

forPageAfterId()

Constrain the query to the next "page" of results after a given ID.

public forPageAfterId([int $perPage = 15 ], int $lastId[, string $column = 'id' ]) : Builder|static
Parameters
$perPage : int = 15
$lastId : int
$column : string = 'id'
Return values
Builder|static

from()

Set the table which the query is targeting.

public from(string $table) : $this
Parameters
$table : string
Return values
$this

get()

Execute the query as a "select" statement.

public get([array<string|int, mixed> $columns = ['*'] ]) : Collection
Parameters
$columns : array<string|int, mixed> = ['*']
Return values
Collection

getBindings()

Get the current query value bindings in a flattened array.

public getBindings() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCountForPagination()

Get the count of the total records for the paginator.

public getCountForPagination([array<string|int, mixed> $columns = ['*'] ]) : int
Parameters
$columns : array<string|int, mixed> = ['*']
Return values
int

getRawBindings()

Get the raw array of bindings.

public getRawBindings() : array<string|int, mixed>
Return values
array<string|int, mixed>

groupBy()

Add a "group by" clause to the query.

public groupBy(array<string|int, mixed> ...$groups) : $this
Parameters
$groups : array<string|int, mixed>
Return values
$this

hasMacro()

Checks if macro is registered.

public static hasMacro(string $name) : bool
Parameters
$name : string
Return values
bool

having()

Add a "having" clause to the query.

public having(string $column[, string|null $operator = null ][, string|null $value = null ][, string $boolean = 'and' ]) : $this
Parameters
$column : string
$operator : string|null = null
$value : string|null = null
$boolean : string = 'and'
Return values
$this

havingRaw()

Add a raw having clause to the query.

public havingRaw(string $sql[, array<string|int, mixed> $bindings = [] ][, string $boolean = 'and' ]) : $this
Parameters
$sql : string
$bindings : array<string|int, mixed> = []
$boolean : string = 'and'
Return values
$this

implode()

Concatenate values of a given column as a string.

public implode(string $column[, string $glue = '' ]) : string
Parameters
$column : string
$glue : string = ''
Return values
string

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

inRandomOrder()

Put the query's results in random order.

public inRandomOrder([string $seed = '' ]) : $this
Parameters
$seed : string = ''
Return values
$this

insert()

Insert a new record into the database.

public insert(array<string|int, mixed> $values) : bool
Parameters
$values : array<string|int, mixed>
Return values
bool

insertGetId()

Insert a new record and get the value of the primary key.

public insertGetId(array<string|int, mixed> $values[, string|null $sequence = null ]) : int
Parameters
$values : array<string|int, mixed>
$sequence : string|null = null
Return values
int

join()

Add a join clause to the query.

public join(string $table, string $first[, string|null $operator = null ][, string|null $second = null ][, string $type = 'inner' ][, bool $where = false ]) : $this
Parameters
$table : string
$first : string
$operator : string|null = null
$second : string|null = null
$type : string = 'inner'
$where : bool = false
Return values
$this

joinWhere()

Add a "join where" clause to the query.

public joinWhere(string $table, string $first, string $operator, string $second[, string $type = 'inner' ]) : Builder|static
Parameters
$table : string
$first : string
$operator : string
$second : string
$type : string = 'inner'
Return values
Builder|static

latest()

Add an "order by" clause for a timestamp to the query.

public latest([string $column = 'created_at' ]) : Builder|static
Parameters
$column : string = 'created_at'
Return values
Builder|static

leftJoin()

Add a left join to the query.

public leftJoin(string $table, string $first[, string|null $operator = null ][, string|null $second = null ]) : Builder|static
Parameters
$table : string
$first : string
$operator : string|null = null
$second : string|null = null
Return values
Builder|static

leftJoinWhere()

Add a "join where" clause to the query.

public leftJoinWhere(string $table, string $first, string $operator, string $second) : Builder|static
Parameters
$table : string
$first : string
$operator : string
$second : string
Return values
Builder|static

limit()

Set the "limit" value of the query.

public limit(int $value) : $this
Parameters
$value : int
Return values
$this

lock()

Lock the selected rows in the table.

public lock([string|bool $value = true ]) : $this
Parameters
$value : string|bool = true
Return values
$this

lockForUpdate()

Lock the selected rows in the table for updating.

public lockForUpdate() : Builder
Return values
Builder

macro()

Register a custom macro.

public static macro(string $name, object|callable $macro) : void
Parameters
$name : string
$macro : object|callable
Return values
void

max()

Retrieve the maximum value of a given column.

public max(string $column) : mixed
Parameters
$column : string
Return values
mixed

mergeBindings()

Merge an array of bindings into our bindings.

public mergeBindings(Builder $query) : $this
Parameters
$query : Builder
Return values
$this

mergeWheres()

Merge an array of where clauses and bindings.

public mergeWheres(array<string|int, mixed> $wheres, array<string|int, mixed> $bindings) : void
Parameters
$wheres : array<string|int, mixed>
$bindings : array<string|int, mixed>
Return values
void

min()

Retrieve the minimum value of a given column.

public min(string $column) : mixed
Parameters
$column : string
Return values
mixed

mixin()

Mix another object into the class.

public static mixin(object $mixin) : void
Parameters
$mixin : object
Return values
void

numericAggregate()

Execute a numeric aggregate function on the database.

public numericAggregate(string $function[, array<string|int, mixed> $columns = ['*'] ]) : float|int
Parameters
$function : string
$columns : array<string|int, mixed> = ['*']
Return values
float|int

offset()

Set the "offset" value of the query.

public offset(int $value) : $this
Parameters
$value : int
Return values
$this

oldest()

Add an "order by" clause for a timestamp to the query.

public oldest([string $column = 'created_at' ]) : Builder|static
Parameters
$column : string = 'created_at'
Return values
Builder|static

on()

Add an "on" clause to the join.

public on(Closure|string $first[, string|null $operator = null ][, string|null $second = null ][, string $boolean = 'and' ]) : $this

On clauses can be chained, e.g.

$join->on('contacts.user_id', '=', 'users.id') ->on('contacts.info_id', '=', 'info.id')

will produce the following SQL:

on contacts.user_id = users.id and contacts.info_id = info.id

Parameters
$first : Closure|string
$operator : string|null = null
$second : string|null = null
$boolean : string = 'and'
Tags
throws
InvalidArgumentException
Return values
$this

orderBy()

Add an "order by" clause to the query.

public orderBy(string $column[, string $direction = 'asc' ]) : $this
Parameters
$column : string
$direction : string = 'asc'
Return values
$this

orderByDesc()

Add a descending "order by" clause to the query.

public orderByDesc(string $column) : $this
Parameters
$column : string
Return values
$this

orderByRaw()

Add a raw "order by" clause to the query.

public orderByRaw(string $sql[, array<string|int, mixed> $bindings = [] ]) : $this
Parameters
$sql : string
$bindings : array<string|int, mixed> = []
Return values
$this

orHaving()

Add a "or having" clause to the query.

public orHaving(string $column[, string|null $operator = null ][, string|null $value = null ]) : Builder|static
Parameters
$column : string
$operator : string|null = null
$value : string|null = null
Return values
Builder|static

orHavingRaw()

Add a raw or having clause to the query.

public orHavingRaw(string $sql[, array<string|int, mixed> $bindings = [] ]) : Builder|static
Parameters
$sql : string
$bindings : array<string|int, mixed> = []
Return values
Builder|static

orOn()

Add an "or on" clause to the join.

public orOn(Closure|string $first[, string|null $operator = null ][, string|null $second = null ]) : JoinClause
Parameters
$first : Closure|string
$operator : string|null = null
$second : string|null = null
Return values
JoinClause

orWhere()

Add an "or where" clause to the query.

public orWhere(string|array<string|int, mixed>|Closure $column[, string|null $operator = null ][, mixed $value = null ]) : Builder|static
Parameters
$column : string|array<string|int, mixed>|Closure
$operator : string|null = null
$value : mixed = null
Return values
Builder|static

orWhereBetween()

Add an or where between statement to the query.

public orWhereBetween(string $column, array<string|int, mixed> $values) : Builder|static
Parameters
$column : string
$values : array<string|int, mixed>
Return values
Builder|static

orWhereColumn()

Add an "or where" clause comparing two columns to the query.

public orWhereColumn(string|array<string|int, mixed> $first[, string|null $operator = null ][, string|null $second = null ]) : Builder|static
Parameters
$first : string|array<string|int, mixed>
$operator : string|null = null
$second : string|null = null
Return values
Builder|static

orWhereDate()

Add an "or where date" statement to the query.

public orWhereDate(string $column, string $operator, string $value) : Builder|static
Parameters
$column : string
$operator : string
$value : string
Return values
Builder|static

orWhereExists()

Add an or exists clause to the query.

public orWhereExists(Closure $callback[, bool $not = false ]) : Builder|static
Parameters
$callback : Closure
$not : bool = false
Return values
Builder|static

orWhereIn()

Add an "or where in" clause to the query.

public orWhereIn(string $column, mixed $values) : Builder|static
Parameters
$column : string
$values : mixed
Return values
Builder|static

orWhereNotBetween()

Add an or where not between statement to the query.

public orWhereNotBetween(string $column, array<string|int, mixed> $values) : Builder|static
Parameters
$column : string
$values : array<string|int, mixed>
Return values
Builder|static

orWhereNotExists()

Add a where not exists clause to the query.

public orWhereNotExists(Closure $callback) : Builder|static
Parameters
$callback : Closure
Return values
Builder|static

orWhereNotIn()

Add an "or where not in" clause to the query.

public orWhereNotIn(string $column, mixed $values) : Builder|static
Parameters
$column : string
$values : mixed
Return values
Builder|static

orWhereNotNull()

Add an "or where not null" clause to the query.

public orWhereNotNull(string $column) : Builder|static
Parameters
$column : string
Return values
Builder|static

orWhereNull()

Add an "or where null" clause to the query.

public orWhereNull(string $column) : Builder|static
Parameters
$column : string
Return values
Builder|static

orWhereRaw()

Add a raw or where clause to the query.

public orWhereRaw(string $sql[, mixed $bindings = [] ]) : Builder|static
Parameters
$sql : string
$bindings : mixed = []
Return values
Builder|static

orWhereTime()

Add an "or where time" statement to the query.

public orWhereTime(string $column, string $operator, int $value) : Builder|static
Parameters
$column : string
$operator : string
$value : int
Return values
Builder|static

paginate()

Paginate the given query into a simple paginator.

public paginate([int $perPage = 15 ][, array<string|int, mixed> $columns = ['*'] ][, string $pageName = 'page' ][, int|null $page = null ]) : LengthAwarePaginator
Parameters
$perPage : int = 15
$columns : array<string|int, mixed> = ['*']
$pageName : string = 'page'
$page : int|null = null
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

prepareValueAndOperator()

Prepare the value and operator for a where clause.

public prepareValueAndOperator(string $value, string $operator[, bool $useDefault = false ]) : array<string|int, mixed>
Parameters
$value : string
$operator : string
$useDefault : bool = false
Tags
throws
InvalidArgumentException
Return values
array<string|int, mixed>

rightJoin()

Add a right join to the query.

public rightJoin(string $table, string $first[, string|null $operator = null ][, string|null $second = null ]) : Builder|static
Parameters
$table : string
$first : string
$operator : string|null = null
$second : string|null = null
Return values
Builder|static

rightJoinWhere()

Add a "right join where" clause to the query.

public rightJoinWhere(string $table, string $first, string $operator, string $second) : Builder|static
Parameters
$table : string
$first : string
$operator : string
$second : string
Return values
Builder|static

select()

Set the columns to be selected.

public select([array<string|int, mixed>|mixed $columns = ['*'] ]) : $this
Parameters
$columns : array<string|int, mixed>|mixed = ['*']
Return values
$this

selectRaw()

Add a new "raw" select expression to the query.

public selectRaw(string $expression[, array<string|int, mixed> $bindings = [] ]) : Builder|static
Parameters
$expression : string
$bindings : array<string|int, mixed> = []
Return values
Builder|static

selectSub()

Add a subselect expression to the query.

public selectSub(Closure|Builder|string $query, string $as) : Builder|static
Parameters
$query : Closure|Builder|string
$as : string
Tags
throws
InvalidArgumentException
Return values
Builder|static

setBindings()

Set the bindings on the query builder.

public setBindings(array<string|int, mixed> $bindings[, string $type = 'where' ]) : $this
Parameters
$bindings : array<string|int, mixed>
$type : string = 'where'
Tags
throws
InvalidArgumentException
Return values
$this

sharedLock()

Share lock the selected rows in the table.

public sharedLock() : Builder
Return values
Builder

simplePaginate()

Get a paginator only supporting simple next and previous links.

public simplePaginate([int $perPage = 15 ][, array<string|int, mixed> $columns = ['*'] ][, string $pageName = 'page' ][, int|null $page = null ]) : Paginator

This is more efficient on larger data-sets, etc.

Parameters
$perPage : int = 15
$columns : array<string|int, mixed> = ['*']
$pageName : string = 'page'
$page : int|null = null
Return values
Paginator

skip()

Alias to set the "offset" value of the query.

public skip(int $value) : Builder|static
Parameters
$value : int
Return values
Builder|static

sum()

Retrieve the sum of the values of a given column.

public sum(string $column) : mixed
Parameters
$column : string
Return values
mixed

take()

Alias to set the "limit" value of the query.

public take(int $value) : Builder|static
Parameters
$value : int
Return values
Builder|static

tap()

Pass the query to a given callback.

public tap(Closure $callback) : Builder
Parameters
$callback : Closure
Return values
Builder

toSql()

Get the SQL representation of the query.

public toSql() : string
Return values
string

truncate()

Run a truncate statement on the table.

public truncate() : void
Return values
void

union()

Add a union statement to the query.

public union(Builder|Closure $query[, bool $all = false ]) : Builder|static
Parameters
$query : Builder|Closure
$all : bool = false
Return values
Builder|static

unionAll()

Add a union all statement to the query.

public unionAll(Builder|Closure $query) : Builder|static
Parameters
$query : Builder|Closure
Return values
Builder|static

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

updateOrInsert()

Insert or update a record matching the attributes, and fill it with values.

public updateOrInsert(array<string|int, mixed> $attributes[, array<string|int, mixed> $values = [] ]) : bool
Parameters
$attributes : array<string|int, mixed>
$values : array<string|int, mixed> = []
Return values
bool

useWritePdo()

Use the write pdo for query.

public useWritePdo() : $this
Return values
$this

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[, mixed $operator = null ][, mixed $value = null ][, string $boolean = 'and' ]) : $this
Parameters
$column : string|array<string|int, mixed>|Closure
$operator : mixed = null
$value : mixed = null
$boolean : string = 'and'
Return values
$this

whereBetween()

Add a where between statement to the query.

public whereBetween(string $column, array<string|int, mixed> $values[, string $boolean = 'and' ][, bool $not = false ]) : $this
Parameters
$column : string
$values : array<string|int, mixed>
$boolean : string = 'and'
$not : bool = false
Return values
$this

whereColumn()

Add a "where" clause comparing two columns to the query.

public whereColumn(string|array<string|int, mixed> $first[, string|null $operator = null ][, string|null $second = null ][, string|null $boolean = 'and' ]) : Builder|static
Parameters
$first : string|array<string|int, mixed>
$operator : string|null = null
$second : string|null = null
$boolean : string|null = 'and'
Return values
Builder|static

whereDate()

Add a "where date" statement to the query.

public whereDate(string $column, string $operator[, mixed $value = null ][, string $boolean = 'and' ]) : Builder|static
Parameters
$column : string
$operator : string
$value : mixed = null
$boolean : string = 'and'
Return values
Builder|static

whereDay()

Add a "where day" statement to the query.

public whereDay(string $column, string $operator[, mixed $value = null ][, string $boolean = 'and' ]) : Builder|static
Parameters
$column : string
$operator : string
$value : mixed = null
$boolean : string = 'and'
Return values
Builder|static

whereExists()

Add an exists clause to the query.

public whereExists(Closure $callback[, string $boolean = 'and' ][, bool $not = false ]) : $this
Parameters
$callback : Closure
$boolean : string = 'and'
$not : bool = false
Return values
$this

whereIn()

Add a "where in" clause to the query.

public whereIn(string $column, mixed $values[, string $boolean = 'and' ][, bool $not = false ]) : $this
Parameters
$column : string
$values : mixed
$boolean : string = 'and'
$not : bool = false
Return values
$this

whereMonth()

Add a "where month" statement to the query.

public whereMonth(string $column, string $operator[, mixed $value = null ][, string $boolean = 'and' ]) : Builder|static
Parameters
$column : string
$operator : string
$value : mixed = null
$boolean : string = 'and'
Return values
Builder|static

whereNested()

Add a nested where statement to the query.

public whereNested(Closure $callback[, string $boolean = 'and' ]) : Builder|static
Parameters
$callback : Closure
$boolean : string = 'and'
Return values
Builder|static

whereNotBetween()

Add a where not between statement to the query.

public whereNotBetween(string $column, array<string|int, mixed> $values[, string $boolean = 'and' ]) : Builder|static
Parameters
$column : string
$values : array<string|int, mixed>
$boolean : string = 'and'
Return values
Builder|static

whereNotExists()

Add a where not exists clause to the query.

public whereNotExists(Closure $callback[, string $boolean = 'and' ]) : Builder|static
Parameters
$callback : Closure
$boolean : string = 'and'
Return values
Builder|static

whereNotIn()

Add a "where not in" clause to the query.

public whereNotIn(string $column, mixed $values[, string $boolean = 'and' ]) : Builder|static
Parameters
$column : string
$values : mixed
$boolean : string = 'and'
Return values
Builder|static

whereNotNull()

Add a "where not null" clause to the query.

public whereNotNull(string $column[, string $boolean = 'and' ]) : Builder|static
Parameters
$column : string
$boolean : string = 'and'
Return values
Builder|static

whereNull()

Add a "where null" clause to the query.

public whereNull(string $column[, string $boolean = 'and' ][, bool $not = false ]) : $this
Parameters
$column : string
$boolean : string = 'and'
$not : bool = false
Return values
$this

whereRaw()

Add a raw where clause to the query.

public whereRaw(string $sql[, mixed $bindings = [] ][, string $boolean = 'and' ]) : $this
Parameters
$sql : string
$bindings : mixed = []
$boolean : string = 'and'
Return values
$this

whereTime()

Add a "where time" statement to the query.

public whereTime(string $column, string $operator, int $value[, string $boolean = 'and' ]) : Builder|static
Parameters
$column : string
$operator : string
$value : int
$boolean : string = 'and'
Return values
Builder|static

whereYear()

Add a "where year" statement to the query.

public whereYear(string $column, string $operator[, mixed $value = null ][, string $boolean = 'and' ]) : Builder|static
Parameters
$column : string
$operator : string
$value : mixed = null
$boolean : string = 'and'
Return values
Builder|static

addArrayOfWheres()

Add an array of where clauses to the query.

protected addArrayOfWheres(array<string|int, mixed> $column, string $boolean[, string $method = 'where' ]) : $this
Parameters
$column : array<string|int, mixed>
$boolean : string
$method : string = 'where'
Return values
$this

addDateBasedWhere()

Add a date based (year, month, day, time) statement to the query.

protected addDateBasedWhere(string $type, string $column, string $operator, int $value[, string $boolean = 'and' ]) : $this
Parameters
$type : string
$column : string
$operator : string
$value : int
$boolean : string = 'and'
Return values
$this

addDynamic()

Add a single dynamic where clause statement to the query.

protected addDynamic(string $segment, string $connector, array<string|int, mixed> $parameters, int $index) : void
Parameters
$segment : string
$connector : string
$parameters : array<string|int, mixed>
$index : int
Return values
void

cleanBindings()

Remove all of the expressions from a list of bindings.

protected cleanBindings(array<string|int, mixed> $bindings) : array<string|int, mixed>
Parameters
$bindings : array<string|int, mixed>
Return values
array<string|int, mixed>

enforceOrderBy()

Throw an exception if the query doesn't have an orderBy clause.

protected enforceOrderBy() : void
Tags
throws
RuntimeException
Return values
void

invalidOperator()

Determine if the given operator is supported.

protected invalidOperator(string $operator) : bool
Parameters
$operator : string
Return values
bool

invalidOperatorAndValue()

Determine if the given operator and value combination is legal.

protected invalidOperatorAndValue(string $operator, mixed $value) : bool

Prevents using Null values with invalid operators.

Parameters
$operator : string
$value : mixed
Return values
bool

parseSubSelect()

Parse the sub-select query into SQL and bindings.

protected parseSubSelect(mixed $query) : array<string|int, mixed>
Parameters
$query : mixed
Return values
array<string|int, mixed>

removeExistingOrdersFor()

Get an array with all orders with a given column removed.

protected removeExistingOrdersFor(string $column) : array<string|int, mixed>
Parameters
$column : string
Return values
array<string|int, mixed>

runPaginationCountQuery()

Run a pagination count query.

protected runPaginationCountQuery([array<string|int, mixed> $columns = ['*'] ]) : array<string|int, mixed>
Parameters
$columns : array<string|int, mixed> = ['*']
Return values
array<string|int, mixed>

runSelect()

Run the query as a "select" statement against the connection.

protected runSelect() : array<string|int, mixed>
Return values
array<string|int, mixed>

setAggregate()

Set the aggregate property without running the query.

protected setAggregate(string $function, array<string|int, mixed> $columns) : $this
Parameters
$function : string
$columns : array<string|int, mixed>
Return values
$this

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>
Return values
Paginator

stripTableForPluck()

Strip off the table name or alias from a column identifier.

protected stripTableForPluck(string $column) : string|null
Parameters
$column : string
Return values
string|null

whereInExistingQuery()

Add an external sub-select to the query.

protected whereInExistingQuery(string $column, Builder|static $query, string $boolean, bool $not) : $this
Parameters
$column : string
$query : Builder|static
$boolean : string
$not : bool
Return values
$this

whereInSub()

Add a where in with a sub-select to the query.

protected whereInSub(string $column, Closure $callback, string $boolean, bool $not) : $this
Parameters
$column : string
$callback : Closure
$boolean : string
$not : bool
Return values
$this

whereSub()

Add a full sub-select to the query.

protected whereSub(string $column, string $operator, Closure $callback, string $boolean) : $this
Parameters
$column : string
$operator : string
$callback : Closure
$boolean : string
Return values
$this

withoutSelectAliases()

Remove the column aliases since they will break count queries.

protected withoutSelectAliases(array<string|int, mixed> $columns) : array<string|int, mixed>
Parameters
$columns : array<string|int, mixed>
Return values
array<string|int, mixed>

Search results