class JoinClause extends Builder

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
ConnectionInterface $connection

The database connection instance.

from  Builder
Grammar $grammar

The database query grammar instance.

from  Builder
Processor $processor

The database query post processor instance.

from  Builder
TBindingType, list<mixed>> $bindings

The current query value bindings.

from  Builder
null|Expression|string>} $aggregate

An aggregate function and column to be run.

from  Builder
null|Expression|string> $columns

The columns that should be returned.

from  Builder
bool|array $distinct

Indicates if the query returns distinct results.

from  Builder
Expression|string|null $from

The table which the query is targeting.

from  Builder
protected string|null $fromAlias

The logical alias explicitly supplied for the query source.

from  Builder
IndexHint|null $indexHint

The index hint for the query.

from  Builder
array|null $joins

The table joins for the query.

from  Builder
array $wheres

The where constraints for the query.

from  Builder
protected bool $hasSelectKeysetConditions

Whether paging predicates belong to this SELECT or its union result.

from  Builder
protected bool $hasUnionKeysetConditions from  Builder
protected bool $hasKeysetExpressions

Whether a cursor compares a selected expression.

from  Builder
protected array $removedKeysetOrders

The SELECT orders removed by paging, in removal order.

from  Builder
array|null $groups

The groupings for the query.

from  Builder
array|null $havings

The having constraints for the query.

from  Builder
array|null $orders

The orderings for the query.

from  Builder
int|null $limit

The maximum number of records to return.

from  Builder
array|null $groupLimit

The maximum number of records to return per group.

from  Builder
int|null $offset

The number of records to skip.

from  Builder
array|null $unions

The query union statements.

from  Builder
int|null $unionLimit

The maximum number of union records to return.

from  Builder
int|null $unionOffset

The number of union records to skip.

from  Builder
array|null $unionOrders

The orderings for the union query.

from  Builder
string|bool|null $lock

Indicates whether row locking is being used.

from  Builder
bool $skipLocked

Whether to skip rows locked by another transaction.

from  Builder
int|null $timeout

The query execution timeout in seconds.

from  Builder
array $beforeQueryCallbacks

The callbacks that should be invoked before the query is executed.

from  Builder
protected TValue>|void> $afterQueryCallbacks

The callbacks that should be invoked after retrieving data from the database.

from  Builder
string[] $operators

All of the available clause operators.

from  Builder
string[] $bitwiseOperators

All of the available bitwise operators.

from  Builder
bool $useWritePdo

Whether to use the write connection for the select.

from  Builder
array $fetchUsing

The PDO fetch mode arguments for the query.

from  Builder
protected array|null $fetchUsingOverride

The scoped PDO fetch mode arguments for the current query, or null when no override is active.

from  Builder
string $type

The type of join being performed.

Expression|string $table

The table the join clause is joining to.

protected ConnectionInterface $parentConnection

The connection of the parent query builder.

protected Grammar $parentGrammar

The grammar of the parent query builder.

protected Processor $parentProcessor

The processor of the parent query builder.

protected string $parentClass

The class name of the parent query builder.

Methods

wherePast(array|string $columns)

Add a where clause to determine if a "date" column is in the past to the query.

whereNowOrPast(array|string $columns)

Add a where clause to determine if a "date" column is in the past or now to the query.

orWherePast(array|string $columns)

Add an "or where" clause to determine if a "date" column is in the past to the query.

orWhereNowOrPast(array|string $columns)

Add a where clause to determine if a "date" column is in the past or now to the query.

whereFuture(array|string $columns)

Add a where clause to determine if a "date" column is in the future to the query.

whereNowOrFuture(array|string $columns)

Add a where clause to determine if a "date" column is in the future or now to the query.

orWhereFuture(array|string $columns)

Add an "or where" clause to determine if a "date" column is in the future to the query.

orWhereNowOrFuture(array|string $columns)

Add an "or where" clause to determine if a "date" column is in the future or now to the query.

wherePastOrFuture(array|string $columns, string $operator, string $boolean)

Add an "where" clause to determine if a "date" column is in the past or future.

whereToday(array|string $columns, string $boolean = 'and')

Add a "where date" clause to determine if a "date" column is today to the query.

whereBeforeToday(array|string $columns)

Add a "where date" clause to determine if a "date" column is before today.

whereTodayOrBefore(array|string $columns)

Add a "where date" clause to determine if a "date" column is today or before to the query.

whereAfterToday(array|string $columns)

Add a "where date" clause to determine if a "date" column is after today.

whereTodayOrAfter(array|string $columns)

Add a "where date" clause to determine if a "date" column is today or after to the query.

orWhereToday(array|string $columns)

Add an "or where date" clause to determine if a "date" column is today to the query.

orWhereBeforeToday(array|string $columns)

Add an "or where date" clause to determine if a "date" column is before today.

orWhereTodayOrBefore(array|string $columns)

Add an "or where date" clause to determine if a "date" column is today or before to the query.

orWhereAfterToday(array|string $columns)

Add an "or where date" clause to determine if a "date" column is after today.

orWhereTodayOrAfter(array|string $columns)

Add an "or where date" clause to determine if a "date" column is today or after to the query.

whereTodayBeforeOrAfter(array|string $columns, string $operator, string $boolean)

Add a "where date" clause to determine if a "date" column is today or after to the query.

mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

bool
chunk(int $count, callable $callback)

Chunk the results of the query.

chunkMap(callable $callback, int $count = 1000)

Run a map over each item while chunking.

bool
each(callable $callback, int $count = 1000)

Execute a callback over each item while chunking.

bool
chunkById(int $count, callable $callback, string|null $column = null, string|null $alias = null)

Chunk the results of a query by comparing IDs.

bool
chunkByIdDesc(int $count, callable $callback, string|null $column = null, string|null $alias = null)

Chunk the results of a query by comparing IDs in descending order.

bool
orderedChunkById(int $count, callable $callback, string|null $column = null, string|null $alias = null, SortDirection|bool $descending = false)

Chunk the results of a query by comparing IDs in a given order.

bool
eachById(callable $callback, int $count = 1000, string|null $column = null, string|null $alias = null)

Execute a callback over each item while chunking by ID.

lazy(int $chunkSize = 1000)

Query lazily, by chunks of the given size.

lazyById(int $chunkSize = 1000, string|null $column = null, string|null $alias = null)

Query lazily, by chunking the results of a query by comparing IDs.

lazyByIdDesc(int $chunkSize = 1000, string|null $column = null, string|null $alias = null)

Query lazily, by chunking the results of a query by comparing IDs in descending order.

orderedLazyById(int $chunkSize = 1000, string|null $column = null, string|null $alias = null, SortDirection|bool $descending = false)

Query lazily, by chunking the results of a query by comparing IDs in a given order.

mixed
getLastIdFromChunk(mixed $result, string $alias)

Get the ID of the last result of a chunk to continue paging from.

mixed
getNextPageIdFromChunk(mixed $result, string $column, string $alias)

Prepare the last chunk ID for comparison with the paging column.

string
getPagingAttribute(Model $model, string $column)

Get the model attribute behind a qualified paging column.

null|TValue
first(array|string $columns = ['*'])

Execute the query and get the first result.

TValue
firstOrFail(array|string $columns = ['*'], string|null $message = null)

Execute the query and get the first result or throw an exception.

TValue
sole(array|string $columns = ['*'])

Execute the query and get the first result if it's the sole matching record.

paginateUsingCursor(int $perPage, array|string $columns = ['*'], string $cursorName = 'cursor', Cursor|string|null $cursor = null)

Paginate the given query using a cursor paginator.

getBuilderForCursorPage()

Get the builder that owns cursor binding and page execution.

mixed
getCursorParameterBinding(Cursor $cursor, string $parameter)

Get a cursor parameter for database binding.

string
getOriginalColumnNameForCursorPagination(Builder|Builder $builder, string $parameter)

Get the original column name of the given column, without any aliasing.

bool
isCursorExpression(Builder $query, string $parameter, string $original)

Determine whether the resolved cursor column is a declared SQL expression.

paginator(Collection $items, int $total, int $perPage, int $currentPage, array $options)

Create a new length-aware paginator instance.

simplePaginator(Collection $items, int $perPage, int $currentPage, array $options)

Create a new simple paginator instance.

cursorPaginator(Collection $items, int $perPage, Cursor|null $cursor, array $options)

Create a new cursor paginator instance.

tap(callable $callback)

Pass the query to a given callback and then return it.

TReturn is null|TReturn)
pipe(callable $callback)

Pass the query to a given callback and return the result.

explain()

Explain the query.

mixed
forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

mixed
forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

static never
throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

__construct(Builder $parentQuery, string $type, Expression|string $table)

Create a new join clause instance.

select(mixed $columns = ['*'])

Set the columns to be selected.

from  Builder
selectSub(Closure|Builder|Builder|Relation|string $query, string $as)

Add a subselect expression to the query.

from  Builder
selectExpression(Expression|string $expression, string $as)

Add a select expression to the query.

from  Builder
selectRaw(string $expression, array $bindings = [])

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

from  Builder
fromSub(Closure|Builder|Builder|Relation|string $query, string $as)

Makes "from" fetch from a subquery.

from  Builder
fromRaw(Expression|string $expression, mixed $bindings = [])

Add a raw "from" clause to the query.

from  Builder
array
createSub(Closure|Builder|Builder|Relation|string $query)

Creates a subquery and parse it.

from  Builder
array
parseSub(mixed $query)

Parse the subquery into SQL and bindings.

from  Builder
prependDatabaseNameIfCrossDatabaseQuery(Builder $query)

Prepend the database name if the given query is on another database.

from  Builder
addSelect(mixed $column)

Add a new select column to the query.

from  Builder
string
getDefaultSelectColumn()

Get the wildcard selection for the query's primary source.

from  Builder
selectVectorDistance(Expression|string $column, Collection|Arrayable|array|string $vector, string|null $as = null)

Add a vector-similarity selection to the query.

from  Builder
distinct()

Force the query to only return distinct results.

from  Builder
from(Closure|Builder|Builder|Relation|Expression|string $table, string|null $as = null)

Set the table which the query is targeting.

from  Builder
string|null
getFromAlias()

Get the alias or table name that qualifies the query's source columns.

from  Builder
useIndex(string $index)

Add an index hint to suggest a query index.

from  Builder
forceIndex(string $index)

Add an index hint to force a query index.

from  Builder
ignoreIndex(string $index)

Add an index hint to ignore a query index.

from  Builder
join(Expression|string $table, Closure|Expression|string $first, Expression|string|null $operator = null, mixed $second = null, string $type = 'inner', bool $where = false)

Add a "join" clause to the query.

from  Builder
joinWhere(Expression|string $table, Closure|Expression|string $first, string $operator, mixed $second, string $type = 'inner')

Add a "join where" clause to the query.

from  Builder
joinSub(Closure|Builder|Builder|Relation|string $query, string $as, Closure|Expression|string $first, Expression|string|null $operator = null, mixed $second = null, string $type = 'inner', bool $where = false)

Add a "subquery join" clause to the query.

from  Builder
joinLateral(Closure|Builder|Builder|Relation|string $query, string $as, string $type = 'inner')

Add a "lateral join" clause to the query.

from  Builder
leftJoinLateral(Closure|Builder|Builder|Relation|string $query, string $as)

Add a lateral left join to the query.

from  Builder
leftJoin(Expression|string $table, Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null)

Add a left join to the query.

from  Builder
leftJoinWhere(Expression|string $table, Closure|Expression|string $first, string $operator, mixed $second)

Add a "join where" clause to the query.

from  Builder
leftJoinSub(Closure|Builder|Builder|Relation|string $query, string $as, Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null)

Add a subquery left join to the query.

from  Builder
rightJoin(Expression|string $table, Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null)

Add a right join to the query.

from  Builder
rightJoinWhere(Expression|string $table, Closure|Expression|string $first, string $operator, mixed $second)

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

from  Builder
rightJoinSub(Closure|Builder|Builder|Relation|string $query, string $as, Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null)

Add a subquery right join to the query.

from  Builder
crossJoin(Expression|string $table, Closure|Expression|string|null $first = null, Expression|string|null $operator = null, Expression|string|null $second = null)

Add a "cross join" clause to the query.

from  Builder
crossJoinSub(Closure|Builder|Builder|Relation|string $query, string $as)

Add a subquery cross join to the query.

from  Builder
straightJoin(Expression|string $table, Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null)

Add a straight join to the query.

from  Builder
straightJoinWhere(Expression|string $table, Closure|Expression|string $first, string $operator, mixed $second)

Add a straight join where clause to the query.

from  Builder
straightJoinSub(Closure|Builder|Builder|Relation|string $query, string $as, Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null)

Add a subquery straight join to the query.

from  Builder
newJoinClause(Builder $parentQuery, string $type, Expression|string $table)

Get a new "join" clause.

from  Builder
newJoinLateralClause(Builder $parentQuery, string $type, Expression|string $table)

Get a new "join lateral" clause.

from  Builder
mergeWheres(array $wheres, array $bindings)

Merge an array of "where" clauses and bindings.

from  Builder
where(Closure|Builder|Builder|Relation|Expression|array|string $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Add a basic "where" clause to the query.

from  Builder
addArrayOfWheres(array $column, string $boolean, string $method = 'where')

Add an array of "where" clauses to the query.

from  Builder
array
prepareValueAndOperator(mixed $value, mixed $operator, bool $useDefault = false)

Prepare the value and operator for a where clause.

from  Builder
bool
invalidOperatorAndValue(mixed $operator, mixed $value)

Determine if the given operator and value combination is legal.

from  Builder
bool
invalidOperator(mixed $operator)

Determine if the given operator is supported.

from  Builder
bool
isBitwiseOperator(string $operator)

Determine if the operator is a bitwise operator.

from  Builder
orWhere(Closure|Builder|Builder|Relation|Expression|array|string $column, mixed $operator = null, mixed $value = null)

Add an "or where" clause to the query.

from  Builder
whereNot(Closure|Builder|Builder|Relation|Expression|array|string $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')

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

from  Builder
orWhereNot(Closure|Builder|Builder|Relation|Expression|array|string $column, mixed $operator = null, mixed $value = null)

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

from  Builder
whereColumn(Expression|string|array $first, Expression|string|null $operator = null, Expression|string|null $second = null, string $boolean = 'and')

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

from  Builder
orWhereColumn(Expression|string|array $first, Expression|string|null $operator = null, Expression|string|null $second = null)

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

from  Builder
whereVectorSimilarTo(Expression|string $column, Collection|Arrayable|array|string $vector, float $minSimilarity = 0.6, bool $order = true)

Add a vector similarity clause to the query, filtering by minimum similarity and ordering by similarity.

from  Builder
whereVectorDistanceLessThan(Expression|string $column, Collection|Arrayable|array|string $vector, float $maxDistance, string $boolean = 'and')

Add a vector distance "where" clause to the query.

from  Builder
orWhereVectorDistanceLessThan(Expression|string $column, Collection|Arrayable|array|string $vector, float $maxDistance)

Add a vector distance "or where" clause to the query.

from  Builder
whereRaw(Expression|string $sql, mixed $bindings = [], string $boolean = 'and')

Add a raw "where" clause to the query.

from  Builder
orWhereRaw(string $sql, mixed $bindings = [])

Add a raw "or where" clause to the query.

from  Builder
whereBinary(Expression|string $column, string $value, string $boolean = 'and', bool $not = false)

Add a "where binary" clause to the query.

from  Builder
orWhereBinary(Expression|string $column, string $value)

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

from  Builder
whereNotBinary(Expression|string $column, string $value, string $boolean = 'and')

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

from  Builder
orWhereNotBinary(Expression|string $column, string $value)

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

from  Builder
whereLike(Expression|string $column, string $value, bool $caseSensitive = false, string $boolean = 'and', bool $not = false)

Add a "where like" clause to the query.

from  Builder
orWhereLike(Expression|string $column, string $value, bool $caseSensitive = false)

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

from  Builder
whereNotLike(Expression|string $column, string $value, bool $caseSensitive = false, string $boolean = 'and')

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

from  Builder
orWhereNotLike(Expression|string $column, string $value, bool $caseSensitive = false)

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

from  Builder
whereNullSafeEquals(Expression|string $column, mixed $value, string $boolean = 'and')

Add a null-safe equality clause to the query.

from  Builder
orWhereNullSafeEquals(Expression|string $column, mixed $value)

Add an "or" null-safe equality clause to the query.

from  Builder
whereIn(Expression|string $column, mixed $values, string $boolean = 'and', bool $not = false)

Add a "where in" clause to the query.

from  Builder
orWhereIn(Expression|string $column, mixed $values)

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

from  Builder
whereNotIn(Expression|string $column, mixed $values, string $boolean = 'and')

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

from  Builder
orWhereNotIn(Expression|string $column, mixed $values)

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

from  Builder
whereIntegerInRaw(string $column, Arrayable|array $values, string $boolean = 'and', bool $not = false)

Add a "where in raw" clause for integer values to the query.

from  Builder
orWhereIntegerInRaw(string $column, Arrayable|array $values)

Add an "or where in raw" clause for integer values to the query.

from  Builder
whereIntegerNotInRaw(string $column, Arrayable|array $values, string $boolean = 'and')

Add a "where not in raw" clause for integer values to the query.

from  Builder
orWhereIntegerNotInRaw(string $column, Arrayable|array $values)

Add an "or where not in raw" clause for integer values to the query.

from  Builder
whereNull(string|array|Expression $columns, string $boolean = 'and', bool $not = false)

Add a "where null" clause to the query.

from  Builder
orWhereNull(string|array|Expression $column)

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

from  Builder
whereNotNull(string|array|Expression $columns, string $boolean = 'and')

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

from  Builder
whereBetween(Closure|Builder|Builder|Relation|Expression|string $column, iterable $values, string $boolean = 'and', bool $not = false)

Add a "where between" statement to the query.

from  Builder
whereBetweenColumns(Closure|Builder|Builder|Relation|Expression|string $column, array $values, string $boolean = 'and', bool $not = false)

Add a "where between" statement using columns to the query.

from  Builder
orWhereBetween(Closure|Builder|Builder|Relation|Expression|string $column, iterable $values)

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

from  Builder
orWhereBetweenColumns(Closure|Builder|Builder|Relation|Expression|string $column, array $values)

Add an "or where between" statement using columns to the query.

from  Builder
whereNotBetween(Closure|Builder|Builder|Relation|Expression|string $column, iterable $values, string $boolean = 'and')

Add a "where not between" statement to the query.

from  Builder
whereNotBetweenColumns(Closure|Builder|Builder|Relation|Expression|string $column, array $values, string $boolean = 'and')

Add a "where not between" statement using columns to the query.

from  Builder
orWhereNotBetween(Closure|Builder|Builder|Relation|Expression|string $column, iterable $values)

Add an "or where not between" statement to the query.

from  Builder
orWhereNotBetweenColumns(Closure|Builder|Builder|Relation|Expression|string $column, array $values)

Add an "or where not between" statement using columns to the query.

from  Builder
whereValueBetween(mixed $value, array $columns, string $boolean = 'and', bool $not = false)

Add a "where between columns" statement using a value to the query.

from  Builder
orWhereValueBetween(mixed $value, array $columns)

Add an "or where between columns" statement using a value to the query.

from  Builder
whereValueNotBetween(mixed $value, array $columns, string $boolean = 'and')

Add a "where not between columns" statement using a value to the query.

from  Builder
orWhereValueNotBetween(mixed $value, array $columns)

Add an "or where not between columns" statement using a value to the query.

from  Builder
orWhereNotNull(array|Expression|string $column)

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

from  Builder
whereDate(Expression|Stringable|string $column, mixed $operator, mixed $value = null, string $boolean = 'and')

Add a "where date" statement to the query.

from  Builder
orWhereDate(Expression|Stringable|string $column, mixed $operator, mixed $value = null)

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

from  Builder
whereTime(Expression|Stringable|string $column, mixed $operator, mixed $value = null, string $boolean = 'and')

Add a "where time" statement to the query.

from  Builder
orWhereTime(Expression|Stringable|string $column, mixed $operator, mixed $value = null)

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

from  Builder
whereDay(Expression|Stringable|string $column, mixed $operator, mixed $value = null, string $boolean = 'and')

Add a "where day" statement to the query.

from  Builder
orWhereDay(Expression|Stringable|string $column, mixed $operator, mixed $value = null)

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

from  Builder
whereMonth(Expression|Stringable|string $column, mixed $operator, mixed $value = null, string $boolean = 'and')

Add a "where month" statement to the query.

from  Builder
orWhereMonth(Expression|Stringable|string $column, mixed $operator, mixed $value = null)

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

from  Builder
whereYear(Expression|Stringable|string $column, mixed $operator, mixed $value = null, string $boolean = 'and')

Add a "where year" statement to the query.

from  Builder
orWhereYear(Expression|Stringable|string $column, mixed $operator, mixed $value = null)

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

from  Builder
addDateBasedWhere(string $type, Expression|Stringable|string $column, string $operator, mixed $value, string $boolean = 'and')

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

from  Builder
whereNested(Closure $callback, string $boolean = 'and')

Add a nested "where" statement to the query.

from  Builder
forNestedWhere()

Create a new query instance for nested where condition.

from  Builder
addNestedWhereQuery(Builder $query, string $boolean = 'and')

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

from  Builder
whereSub(Expression|string $column, string $operator, Closure|Builder|Builder|Relation $callback, string $boolean)

Add a full sub-select to the query.

from  Builder
whereExists(Closure|Builder|Builder $callback, string $boolean = 'and', bool $not = false)

Add an "exists" clause to the query.

from  Builder
orWhereExists(Closure|Builder|Builder $callback, bool $not = false)

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

from  Builder
whereNotExists(Closure|Builder|Builder $callback, string $boolean = 'and')

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

from  Builder
orWhereNotExists(Closure|Builder|Builder $callback)

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

from  Builder
addWhereExistsQuery(Builder $query, string $boolean = 'and', bool $not = false)

Add an "exists" clause to the query.

from  Builder
whereRowValues(array $columns, string $operator, array $values, string $boolean = 'and')

Add a where condition using row values.

from  Builder
orWhereRowValues(array $columns, string $operator, array $values)

Adds an or where condition using row values.

from  Builder
whereJsonContains(string $column, mixed $value, string $boolean = 'and', bool $not = false)

Add a "where JSON contains" clause to the query.

from  Builder
orWhereJsonContains(string $column, mixed $value)

Add an "or where JSON contains" clause to the query.

from  Builder
whereJsonDoesntContain(string $column, mixed $value, string $boolean = 'and')

Add a "where JSON not contains" clause to the query.

from  Builder
orWhereJsonDoesntContain(string $column, mixed $value)

Add an "or where JSON not contains" clause to the query.

from  Builder
whereJsonOverlaps(string $column, mixed $value, string $boolean = 'and', bool $not = false)

Add a "where JSON overlaps" clause to the query.

from  Builder
orWhereJsonOverlaps(string $column, mixed $value)

Add an "or where JSON overlaps" clause to the query.

from  Builder
whereJsonDoesntOverlap(string $column, mixed $value, string $boolean = 'and')

Add a "where JSON not overlap" clause to the query.

from  Builder
orWhereJsonDoesntOverlap(string $column, mixed $value)

Add an "or where JSON not overlap" clause to the query.

from  Builder
whereJsonContainsKey(string $column, string $boolean = 'and', bool $not = false)

Add a clause that determines if a JSON path exists to the query.

from  Builder
orWhereJsonContainsKey(string $column)

Add an "or" clause that determines if a JSON path exists to the query.

from  Builder
whereJsonDoesntContainKey(string $column, string $boolean = 'and')

Add a clause that determines if a JSON path does not exist to the query.

from  Builder
orWhereJsonDoesntContainKey(string $column)

Add an "or" clause that determines if a JSON path does not exist to the query.

from  Builder
whereJsonLength(string $column, mixed $operator, mixed $value = null, string $boolean = 'and')

Add a "where JSON length" clause to the query.

from  Builder
orWhereJsonLength(string $column, mixed $operator, mixed $value = null)

Add an "or where JSON length" clause to the query.

from  Builder
dynamicWhere(string $method, array $parameters)

Handles dynamic "where" clauses to the query.

from  Builder
void
addDynamic(string $segment, string $connector, array $parameters, int $index)

Add a single dynamic "where" clause statement to the query.

from  Builder
whereFullText(string|array $columns, string $value, array $options = [], string $boolean = 'and')

Add a "where fulltext" clause to the query.

from  Builder
orWhereFullText(string|array $columns, string $value, array $options = [])

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

from  Builder
whereAll(array $columns, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Add a "where" clause to the query for multiple columns with "and" conditions between them.

from  Builder
orWhereAll(array $columns, mixed $operator = null, mixed $value = null)

Add an "or where" clause to the query for multiple columns with "and" conditions between them.

from  Builder
whereAny(array $columns, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Add a "where" clause to the query for multiple columns with "or" conditions between them.

from  Builder
orWhereAny(array $columns, mixed $operator = null, mixed $value = null)

Add an "or where" clause to the query for multiple columns with "or" conditions between them.

from  Builder
whereNone(array $columns, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Add a "where not" clause to the query for multiple columns where none of the conditions should be true.

from  Builder
orWhereNone(array $columns, mixed $operator = null, mixed $value = null)

Add an "or where not" clause to the query for multiple columns where none of the conditions should be true.

from  Builder
groupBy(array|Expression|string ...$groups)

Add a "group by" clause to the query.

from  Builder
groupByRaw(string $sql, array $bindings = [])

Add a raw "groupBy" clause to the query.

from  Builder
having(Expression|Closure|string $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Add a "having" clause to the query.

from  Builder
orHaving(Expression|Closure|string $column, mixed $operator = null, mixed $value = null)

Add an "or having" clause to the query.

from  Builder
havingNested(Closure $callback, string $boolean = 'and')

Add a nested "having" statement to the query.

from  Builder
addNestedHavingQuery(Builder $query, string $boolean = 'and')

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

from  Builder
havingNull(array|string $columns, string $boolean = 'and', bool $not = false)

Add a "having null" clause to the query.

from  Builder
orHavingNull(string $column)

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

from  Builder
havingNotNull(array|string $columns, string $boolean = 'and')

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

from  Builder
orHavingNotNull(string $column)

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

from  Builder
havingBetween(string $column, iterable $values, string $boolean = 'and', bool $not = false)

Add a "having between" clause to the query.

from  Builder
havingNotBetween(string $column, iterable $values, string $boolean = 'and')

Add a "having not between" clause to the query.

from  Builder
orHavingBetween(string $column, iterable $values)

Add an "or having between" clause to the query.

from  Builder
orHavingNotBetween(string $column, iterable $values)

Add an "or having not between" clause to the query.

from  Builder
array
resolveDatePeriodBounds(DatePeriod $period)

Resolve the start and end dates from a DatePeriod.

from  Builder
havingRaw(string $sql, array $bindings = [], string $boolean = 'and')

Add a raw "having" clause to the query.

from  Builder
orHavingRaw(string $sql, array $bindings = [])

Add a raw "or having" clause to the query.

from  Builder
orderBy(Closure|Builder|Builder|Relation|Expression|string $column, SortDirection|string $direction = SortDirection::Ascending)

Add an "order by" clause to the query.

from  Builder
orderByDesc(Closure|Builder|Builder|Relation|Expression|string $column)

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

from  Builder
latest(Closure|Builder|Builder|Relation|Expression|string $column = 'created_at')

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

from  Builder
oldest(Closure|Builder|Builder|Relation|Expression|string $column = 'created_at')

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

from  Builder
orderByVectorDistance(Expression|string $column, Collection|Arrayable|array|string $vector)

Add a vector-distance "order by" clause to the query.

from  Builder
inRandomOrder(string|int $seed = '')

Put the query's results in random order.

from  Builder
inOrderOf(Expression|string $column, Arrayable|array $values)

Add an "order by" clause to order results by a given sequence of values.

from  Builder
orderByRaw(string $sql, mixed $bindings = [])

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

from  Builder
void
addOrderBindings(array $bindings)

Attach bindings to the last column order so removing it also removes its parameters.

from  Builder
skip(int|null $value)

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

from  Builder
offset(int|null $value)

Set the "offset" value of the query.

from  Builder
take(int|null $value)

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

from  Builder
limit(int|null $value)

Set the "limit" value of the query.

from  Builder
groupLimit(int $value, string $column)

Add a "group limit" clause to the query.

from  Builder
forPage(int $page, int $perPage = 15)

Set the limit and offset for a given page.

from  Builder
forPageBeforeId(int $perPage = 15, mixed $lastId = 0, string $column = 'id')

Constrain the query to the previous "page" of results before a given ID.

from  Builder
forPageAfterId(int $perPage = 15, mixed $lastId = 0, string $column = 'id')

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

from  Builder
reorder(Closure|Builder|Builder|Relation|Expression|string|null $column = null, SortDirection|string $direction = SortDirection::Ascending)

Remove all existing orders and optionally add a new order.

from  Builder
reorderDesc(Closure|Builder|Builder|Relation|Expression|string|null $column)

Add descending "reorder" clause to the query.

from  Builder
array
removeExistingOrdersFor(string $column)

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

from  Builder
array
removeOrdersFor(array $orders, array $bindings, string $column)

Remove matching orders and only their owned parameters.

from  Builder
union(Closure|Builder|Builder $query, bool $all = false)

Add a "union" statement to the query.

from  Builder
unionAll(Closure|Builder|Builder $query)

Add a "union all" statement to the query.

from  Builder
lock(string|bool $value = true)

Lock the selected rows in the table.

from  Builder
lockForUpdate()

Lock the selected rows in the table for updating.

from  Builder
sharedLock()

Share lock the selected rows in the table.

from  Builder
skipLocked()

Skip rows locked by another transaction when supported by the server.

from  Builder
timeout(int|null $seconds)

Set a query execution timeout in seconds.

from  Builder
beforeQuery(callable $callback)

Register a closure to be invoked before the query is executed.

from  Builder
void
applyBeforeQueryCallbacks()

Invoke the "before query" modification callbacks.

from  Builder
afterQuery(Closure $callback)

Register a closure to be invoked after the query is executed.

from  Builder
applyAfterQueryCallbacks(Collection $result)

Invoke the "after query" modification callbacks.

from  Builder
string
toSql()

Get the SQL representation of the query.

from  Builder
string
toRawSql()

Get the raw SQL representation of the query with embedded bindings.

from  Builder
mixed
find(int|string $id, Expression|array|string $columns = ['*'])

Execute a query for a single record by ID.

from  Builder
mixed
findOr(mixed $id, Closure|Expression|array|string $columns = ['*'], Closure|null $callback = null)

Execute a query for a single record by ID or call a callback.

from  Builder
mixed
value(Expression|string $column)

Get a single column's value from the first result of a query.

from  Builder
mixed
rawValue(string $expression, array $bindings = [])

Get a single expression value from the first result of a query.

from  Builder
mixed
soleValue(Expression|string $column)

Get a single column's value from the first result of a query if it's the sole matching record.

from  Builder
get(Expression|array|string $columns = ['*'])

Execute the query as a "select" statement.

from  Builder
array
runSelect()

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

from  Builder
mixed
withoutFetchUsing(callable $callback)

Execute the given callback without custom fetch mode arguments.

from  Builder
withoutGroupLimitKeys(Collection $items)

Remove the group limit keys from the results in the collection.

from  Builder
paginate(int|Closure $perPage = 15, Expression|array|string $columns = ['*'], string $pageName = 'page', int|null $page = null, Closure|int|null $total = null)

Paginate the given query into a simple paginator.

from  Builder
simplePaginate(int $perPage = 15, Expression|array|string $columns = ['*'], string $pageName = 'page', int|null $page = null)

Get a paginator only supporting simple next and previous links.

from  Builder
cursorPaginate(int $perPage = 15, Expression|array|string $columns = ['*'], string $cursorName = 'cursor', Cursor|string|null $cursor = null)

Get a paginator only supporting simple next and previous links.

from  Builder
ensureOrderForCursorPagination(bool $shouldReverse = false)

Ensure the proper order by required for cursor pagination.

from  Builder
void
markKeysetCondition(int $offset, string|null $column = null)

Record the paging predicate and the bindings it owns.

from  Builder
void
prepareCursorOrdering()

Retain membership ordering before cursor traversal reverses it.

from  Builder
bool
restoreKeysetOrdersFrom(Builder $source)

Restore the operation's ordering when a global scope replaces its paging orders.

from  Builder
prioritizeKeysetOrders(bool $limited = false)

Sort an ID iteration by its paging column before any other order.

from  Builder
void
ensureLimitedIterationOrdersById(string $column, bool $descending)

Reject limited ID iteration when another order would choose different rows.

from  Builder
addCursorPaginationConditions(array $orders, array $bindings)

Add cursor comparisons resolved by the calling query or Eloquent builder.

from  Builder
void
groupOrWheresForKeyset()

Keep existing "or" conditions from bypassing the page boundary.

from  Builder
void
addCursorComparisons(array $orders, array $bindings, int $index)

Add the ordered comparisons for a compound cursor.

from  Builder
bool
requiresKeysetIsolation(bool $limitSelectsRows)

Determine whether paging must filter the result of this SELECT.

from  Builder
prepareForSelect()

Prepare a SELECT without changing the logical query retained by its caller.

from  Builder
array
collectKeysetConditions(array $wheres, array $conditions, bool $includeSelect)

Collect paging constraints without rewriting nested groups shared with another query.

from  Builder
array
normalizeKeysetColumns(array $where)

Normalize only framework-owned comparison columns to selected output names.

from  Builder
array
getKeysetSelection(string $column)

Get the source column and output name of a selected entry.

from  Builder
string
getKeysetOutputColumn(string $parameter, bool $source = false)

Get the selected output name for a paging column.

from  Builder
string|null
getKeysetSourceOutputColumn(string $column)

Find the selected output that represents a paging source column.

from  Builder
bool
isSameKeysetSourceColumn(string $left, string $right)

Compare source references without conflating two explicitly qualified columns.

from  Builder
string
resolveKeysetOrderColumn(string $column)

Keep an ID page ordered by its WHERE source when an output alias shadows it.

from  Builder
void
collectKeysetParameters(array $where, array $parameters)

Collect the output columns used by a compound paging constraint.

from  Builder
array
mapUnionKeysetColumns(Builder $member, array $parameters)

Map union output columns only when their correspondence can be proven.

from  Builder
bool
selectsAllSourceColumns()

Determine whether the projection selects only the source's wildcard columns.

from  Builder
applyUnionKeysetConditions(Builder $root, array $conditions, array $parameters)

Apply inherited paging outside member bounds and through unbounded nested unions.

from  Builder
appendKeysetConditions(array $conditions, array $mapping = [], bool $output = false)

Append comparisons using the member's source columns or isolated output names.

from  Builder
array
rebindKeysetColumns(array $where, array $mapping, bool $output)

Rebind only owned comparisons, preserving user predicates and shared nested groups.

from  Builder
void
restoreKeysetOrdering()

Restore membership ordering from live entries and the orders paging removed.

from  Builder
void
isolateKeysetSelect(bool $limitSelectsRows)

Move row selection inside a derived table while retaining the page outside it.

from  Builder
int
getCountForPagination(array $columns = ['*'])

Get the count of the total records for the paginator.

from  Builder
array
runPaginationCountQuery(array $columns = ['*'])

Run a pagination count query.

from  Builder
cloneForPaginationCount()

Clone the existing query instance for usage in a pagination subquery.

from  Builder
array
withoutSelectAliases(array $columns)

Remove the column aliases since they will break count queries.

from  Builder
cursor()

Get a lazy collection for the given query.

from  Builder
void
enforceOrderBy()

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

from  Builder
pluck(Expression|string $column, string|null $key = null)

Get a collection instance containing the values of a given column.

from  Builder
array
pluckWithColumn(Expression|string $column, string|null $key = null)

Get column values and the returned field name for Eloquent attribute conversion.

from  Builder
string|null
stripTableForPluck(Expression|string|null $column)

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

from  Builder
pluckFromObjectColumn(array $queryResult, string $column, string|null $key)

Retrieve column values from rows represented as objects.

from  Builder
pluckFromArrayColumn(array $queryResult, string $column, string|null $key)

Retrieve column values from rows represented as arrays.

from  Builder
string
implode(string $column, string $glue = '')

Concatenate values of a given column as a string.

from  Builder
bool
exists()

Determine if any rows exist for the current query.

from  Builder
bool
doesntExist()

Determine if no rows exist for the current query.

from  Builder
mixed
existsOr(Closure $callback)

Execute the given callback if no rows exist for the current query.

from  Builder
mixed
doesntExistOr(Closure $callback)

Execute the given callback if rows exist for the current query.

from  Builder
int
count(Expression|string $columns = '*')

Retrieve the "count" result of the query.

from  Builder
mixed
min(Expression|string $column)

Retrieve the minimum value of a given column.

from  Builder
mixed
max(Expression|string $column)

Retrieve the maximum value of a given column.

from  Builder
mixed
sum(Expression|string $column)

Retrieve the sum of the values of a given column.

from  Builder
mixed
avg(Expression|string $column)

Retrieve the average of the values of a given column.

from  Builder
mixed
average(Expression|string $column)

Alias for the "avg" method.

from  Builder
mixed
aggregate(string $function, array $columns = ['*'])

Execute an aggregate function on the database.

from  Builder
float|int
numericAggregate(string $function, array $columns = ['*'])

Execute a numeric aggregate function on the database.

from  Builder
setAggregate(string $function, array $columns)

Set the aggregate property without running the query.

from  Builder
bool
shouldPreserveAggregateOrdering()

Determine whether ordering selects rows retained by the aggregate's inner query.

from  Builder
mixed
onceWithColumns(array $columns, callable $callback)

Execute the given callback while selecting the given columns.

from  Builder
bool
insert(array $values)

Insert new records into the database.

from  Builder
int
insertOrIgnore(array $values)

Insert new records into the database while ignoring errors.

from  Builder
insertOrIgnoreReturning(array $values, array $returning = ['*'], array|string|null $uniqueBy = null)

Insert records while ignoring conflicts and return the inserted rows.

from  Builder
int|string
insertGetId(array $values, string|null $sequence = null)

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

from  Builder
int
insertUsing(array $columns, Closure|Builder|Builder|Relation|string $query)

Insert new records into the table using a subquery.

from  Builder
int
insertOrIgnoreUsing(array $columns, Closure|Builder|Builder|Relation|string $query)

Insert new records into the table using a subquery while ignoring errors.

from  Builder
int
update(array $values)

Update records in the database.

from  Builder
int
updateFrom(array $values)

Update records in a PostgreSQL database using the update from syntax.

from  Builder
bool
updateOrInsert(array $attributes, array|callable $values = [])

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

from  Builder
int
upsert(array $values, array|string $uniqueBy, array|null $update = null)

Insert new records or update the existing ones.

from  Builder
int
increment(string $column, mixed $amount = 1, array $extra = [])

Increment a column's value by a given amount.

from  Builder
int
incrementEach(array $columns, array $extra = [])

Increment the given column's values by the given amounts.

from  Builder
int
decrement(string $column, mixed $amount = 1, array $extra = [])

Decrement a column's value by a given amount.

from  Builder
int
decrementEach(array $columns, array $extra = [])

Decrement the given column's values by the given amounts.

from  Builder
int
delete(mixed $id = null)

Delete records from the database.

from  Builder
void
truncate()

Run a "truncate" statement on the table.

from  Builder
newQuery()

Get a new instance of the join clause builder.

forSubQuery()

Create a new query instance for sub-query.

array
getColumns()

Get all of the query builder's columns in a text-only array with all expressions evaluated.

from  Builder
raw(mixed $value)

Create a raw database expression.

from  Builder
getUnionBuilders()

Get the query builder instances that are used in the union of the query.

from  Builder
int|null
getLimit()

Get the "limit" value for the query or null if it's not set.

from  Builder
int|null
getOffset()

Get the "offset" value for the query or null if it's not set.

from  Builder
array
getBindings()

Get the current query value bindings in a flattened array.

from  Builder
array
getBindingsForSelect()

Get the binding groups in the order used by this select statement.

from  Builder
array
getRawBindings()

Get the raw array of bindings.

from  Builder
setBindings(array $bindings, string $type = 'where')

Set the bindings on the query builder.

from  Builder
addBinding(mixed $value, string $type = 'where')

Add a binding to the query.

from  Builder
mixed
castBinding(mixed $value)

Cast the given binding value.

from  Builder
mergeBindings(Builder $query)

Merge an array of bindings into our bindings.

from  Builder
array
cleanBindings(array $bindings)

Remove all of the expressions from a list of bindings.

from  Builder
mixed
flattenValue(mixed $value)

Get a scalar type value from an unknown type of input.

from  Builder
string
defaultKeyName()

Get the default key name of the table.

from  Builder
getConnection()

Get the database connection instance.

from  Builder
void
ensureConnectionSupportsVectors()

Ensure the database connection supports vector queries.

from  Builder
getProcessor()

Get the database query processor instance.

from  Builder
getGrammar()

Get the query grammar instance.

from  Builder
useWritePdo()

Use the write connection when executing the query.

from  Builder
fetchUsing(mixed ...$fetchUsing)

Set the PDO fetch mode arguments for the query.

from  Builder
bool
isQueryable(mixed $value)

Determine if the value is a query builder instance or a Closure.

from  Builder
prepareQueryForEmbedding(Builder $query)

Prepare the query for embedding in another statement.

from  Builder
clone()

Clone the query.

from  Builder
cloneWithout(array $properties)

Clone the query without the given properties.

from  Builder
void
resetProperties(array $properties)

Clear query properties while retaining defaults required by non-nullable types.

from  Builder
cloneWithoutBindings(array $except)

Clone the query without the given bindings.

from  Builder
dump(mixed ...$args)

Dump the current SQL and bindings.

from  Builder
dumpRawSql()

Dump the raw current SQL with embedded bindings.

from  Builder
never
dd()

Die and dump the current SQL and bindings.

from  Builder
never
ddRawSql()

Die and dump the current SQL with embedded bindings.

from  Builder
static void
flushState()

Flush all static state.

from  Builder
on(Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null, string $boolean = 'and')

Add an "on" clause to the join.

orOn(Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null)

Add an "or on" clause to the join.

newParentQuery()

Create a new parent query instance.

Details

BuildsWhereDateClauses wherePast(array|string $columns)

Add a where clause to determine if a "date" column is in the past to the query.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses whereNowOrPast(array|string $columns)

Add a where clause to determine if a "date" column is in the past or now to the query.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses orWherePast(array|string $columns)

Add an "or where" clause to determine if a "date" column is in the past to the query.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses orWhereNowOrPast(array|string $columns)

Add a where clause to determine if a "date" column is in the past or now to the query.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses whereFuture(array|string $columns)

Add a where clause to determine if a "date" column is in the future to the query.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses whereNowOrFuture(array|string $columns)

Add a where clause to determine if a "date" column is in the future or now to the query.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses orWhereFuture(array|string $columns)

Add an "or where" clause to determine if a "date" column is in the future to the query.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses orWhereNowOrFuture(array|string $columns)

Add an "or where" clause to determine if a "date" column is in the future or now to the query.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

protected BuildsWhereDateClauses wherePastOrFuture(array|string $columns, string $operator, string $boolean)

Add an "where" clause to determine if a "date" column is in the past or future.

Parameters

array|string $columns
string $operator
string $boolean

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses whereToday(array|string $columns, string $boolean = 'and')

Add a "where date" clause to determine if a "date" column is today to the query.

Parameters

array|string $columns
string $boolean

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses whereBeforeToday(array|string $columns)

Add a "where date" clause to determine if a "date" column is before today.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses whereTodayOrBefore(array|string $columns)

Add a "where date" clause to determine if a "date" column is today or before to the query.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses whereAfterToday(array|string $columns)

Add a "where date" clause to determine if a "date" column is after today.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses whereTodayOrAfter(array|string $columns)

Add a "where date" clause to determine if a "date" column is today or after to the query.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses orWhereToday(array|string $columns)

Add an "or where date" clause to determine if a "date" column is today to the query.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses orWhereBeforeToday(array|string $columns)

Add an "or where date" clause to determine if a "date" column is before today.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses orWhereTodayOrBefore(array|string $columns)

Add an "or where date" clause to determine if a "date" column is today or before to the query.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses orWhereAfterToday(array|string $columns)

Add an "or where date" clause to determine if a "date" column is after today.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

BuildsWhereDateClauses orWhereTodayOrAfter(array|string $columns)

Add an "or where date" clause to determine if a "date" column is today or after to the query.

Parameters

array|string $columns

Return Value

BuildsWhereDateClauses

protected BuildsWhereDateClauses whereTodayBeforeOrAfter(array|string $columns, string $operator, string $boolean)

Add a "where date" clause to determine if a "date" column is today or after to the query.

Parameters

array|string $columns
string $operator
string $boolean

Return Value

BuildsWhereDateClauses

in Conditionable at line 23
mixed when(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) truthy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in Conditionable at line 56
mixed unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)

Apply the callback if the given "value" is (or resolves to) falsy.

Parameters

mixed $value
callable|null $callback
callable|null $default

Return Value

mixed

in BuildsQueries at line 45
bool chunk(int $count, callable $callback)

Chunk the results of the query.

Parameters

int $count
callable $callback

Return Value

bool

in BuildsQueries at line 101
Collection chunkMap(callable $callback, int $count = 1000)

Run a map over each item while chunking.

Parameters

callable $callback
int $count

Return Value

Collection

in BuildsQueries at line 119
bool each(callable $callback, int $count = 1000)

Execute a callback over each item while chunking.

Parameters

callable $callback
int $count

Return Value

bool

in BuildsQueries at line 137
bool chunkById(int $count, callable $callback, string|null $column = null, string|null $alias = null)

Chunk the results of a query by comparing IDs.

Parameters

int $count
callable $callback
string|null $column
string|null $alias

Return Value

bool

in BuildsQueries at line 147
bool chunkByIdDesc(int $count, callable $callback, string|null $column = null, string|null $alias = null)

Chunk the results of a query by comparing IDs in descending order.

Parameters

int $count
callable $callback
string|null $column
string|null $alias

Return Value

bool

in BuildsQueries at line 157
bool orderedChunkById(int $count, callable $callback, string|null $column = null, string|null $alias = null, SortDirection|bool $descending = false)

Chunk the results of a query by comparing IDs in a given order.

Parameters

int $count
callable $callback
string|null $column
string|null $alias
SortDirection|bool $descending

Return Value

bool

in BuildsQueries at line 230
bool eachById(callable $callback, int $count = 1000, string|null $column = null, string|null $alias = null)

Execute a callback over each item while chunking by ID.

Parameters

callable $callback
int $count
string|null $column
string|null $alias

Return Value

bool

in BuildsQueries at line 248
LazyCollection lazy(int $chunkSize = 1000)

Query lazily, by chunks of the given size.

Parameters

int $chunkSize

Return Value

LazyCollection

in BuildsQueries at line 301
LazyCollection lazyById(int $chunkSize = 1000, string|null $column = null, string|null $alias = null)

Query lazily, by chunking the results of a query by comparing IDs.

Parameters

int $chunkSize
string|null $column
string|null $alias

Return Value

LazyCollection

in BuildsQueries at line 311
LazyCollection lazyByIdDesc(int $chunkSize = 1000, string|null $column = null, string|null $alias = null)

Query lazily, by chunking the results of a query by comparing IDs in descending order.

Parameters

int $chunkSize
string|null $column
string|null $alias

Return Value

LazyCollection

in BuildsQueries at line 324
protected LazyCollection orderedLazyById(int $chunkSize = 1000, string|null $column = null, string|null $alias = null, SortDirection|bool $descending = false)

Query lazily, by chunking the results of a query by comparing IDs in a given order.

Parameters

int $chunkSize
string|null $column
string|null $alias
SortDirection|bool $descending

Return Value

LazyCollection

Exceptions

InvalidArgumentException
RuntimeException

in BuildsQueries at line 392
protected mixed getLastIdFromChunk(mixed $result, string $alias)

Get the ID of the last result of a chunk to continue paging from.

Parameters

mixed $result
string $alias

Return Value

mixed

in BuildsQueries at line 407
protected mixed getNextPageIdFromChunk(mixed $result, string $column, string $alias)

Prepare the last chunk ID for comparison with the paging column.

Parameters

mixed $result
string $column
string $alias

Return Value

mixed

in BuildsQueries at line 425
protected string getPagingAttribute(Model $model, string $column)

Get the model attribute behind a qualified paging column.

Parameters

Model $model
string $column

Return Value

string

in BuildsQueries at line 447
null|TValue first(array|string $columns = ['*'])

Execute the query and get the first result.

Parameters

array|string $columns

Return Value

null|TValue

in BuildsQueries at line 459
TValue firstOrFail(array|string $columns = ['*'], string|null $message = null)

Execute the query and get the first result or throw an exception.

Parameters

array|string $columns
string|null $message

Return Value

TValue

Exceptions

RecordNotFoundException

in BuildsQueries at line 479
TValue sole(array|string $columns = ['*'])

Execute the query and get the first result if it's the sole matching record.

Parameters

array|string $columns

Return Value

TValue

Exceptions

RecordsNotFoundException
MultipleRecordsFoundException

in BuildsQueries at line 499
protected CursorPaginator paginateUsingCursor(int $perPage, array|string $columns = ['*'], string $cursorName = 'cursor', Cursor|string|null $cursor = null)

Paginate the given query using a cursor paginator.

Parameters

int $perPage
array|string $columns
string $cursorName
Cursor|string|null $cursor

Return Value

CursorPaginator

in BuildsQueries at line 561
protected BuildsQueries getBuilderForCursorPage()

Get the builder that owns cursor binding and page execution.

Return Value

BuildsQueries

in BuildsQueries at line 569
protected mixed getCursorParameterBinding(Cursor $cursor, string $parameter)

Get a cursor parameter for database binding.

Parameters

Cursor $cursor
string $parameter

Return Value

mixed

in BuildsQueries at line 579
protected string getOriginalColumnNameForCursorPagination(Builder|Builder $builder, string $parameter)

Get the original column name of the given column, without any aliasing.

Parameters

Builder|Builder $builder
string $parameter

Return Value

string

in BuildsQueries at line 604
protected bool isCursorExpression(Builder $query, string $parameter, string $original)

Determine whether the resolved cursor column is a declared SQL expression.

Parameters

Builder $query
string $parameter
string $original

Return Value

bool

in BuildsQueries at line 629
protected LengthAwarePaginator paginator(Collection $items, int $total, int $perPage, int $currentPage, array $options)

Create a new length-aware paginator instance.

Parameters

Collection $items
int $total
int $perPage
int $currentPage
array $options

Return Value

LengthAwarePaginator

in BuildsQueries at line 639
protected Paginator simplePaginator(Collection $items, int $perPage, int $currentPage, array $options)

Create a new simple paginator instance.

Parameters

Collection $items
int $perPage
int $currentPage
array $options

Return Value

Paginator

in BuildsQueries at line 649
protected CursorPaginator cursorPaginator(Collection $items, int $perPage, Cursor|null $cursor, array $options)

Create a new cursor paginator instance.

Parameters

Collection $items
int $perPage
Cursor|null $cursor
array $options

Return Value

CursorPaginator

in BuildsQueries at line 662
BuildsQueries tap(callable $callback)

Pass the query to a given callback and then return it.

Parameters

callable $callback

Return Value

BuildsQueries

in BuildsQueries at line 677
TReturn is null|TReturn) pipe(callable $callback)

Pass the query to a given callback and return the result.

Parameters

callable $callback

Return Value

TReturn is null|TReturn)

in ExplainsQueries at line 17
Collection explain()

Explain the query.

Return Value

Collection

Exceptions

InvalidArgumentException

in ForwardsCalls at line 22
protected mixed forwardCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in ForwardsCalls at line 52
protected mixed forwardDecoratedCallTo(mixed $object, string $method, array $parameters)

Forward a method call to the given object, returning $this if the forwarded call returned itself.

Parameters

mixed $object
string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in ForwardsCalls at line 66
static protected never throwBadMethodCallException(string $method)

Throw a bad method call exception for the given method.

Parameters

string $method

Return Value

never

Exceptions

BadMethodCallException

in Macroable at line 30
static void macro(string $name, callable|object $macro)

Register a custom macro.

Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 44
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 61
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 72
static void flushMacros()

Flush the existing macros.

Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 83
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 108
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 49
__construct(Builder $parentQuery, string $type, Expression|string $table)

Create a new join clause instance.

Parameters

Builder $parentQuery
string $type
Expression|string $table

in Builder at line 296
Builder select(mixed $columns = ['*'])

Set the columns to be selected.

Parameters

mixed $columns

Return Value

Builder

in Builder at line 322
Builder selectSub(Closure|Builder|Builder|Relation|string $query, string $as)

Add a subselect expression to the query.

Parameters

Closure|Builder|Builder|Relation|string $query
string $as

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 337
Builder selectExpression(Expression|string $expression, string $as)

Add a select expression to the query.

Parameters

Expression|string $expression
string $as

Return Value

Builder

in Builder at line 349
Builder selectRaw(string $expression, array $bindings = [])

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

Parameters

string $expression
array $bindings

Return Value

Builder

in Builder at line 368
Builder fromSub(Closure|Builder|Builder|Relation|string $query, string $as)

Makes "from" fetch from a subquery.

Parameters

Closure|Builder|Builder|Relation|string $query
string $as

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 384
Builder fromRaw(Expression|string $expression, mixed $bindings = [])

Add a raw "from" clause to the query.

Parameters

Expression|string $expression
mixed $bindings

Return Value

Builder

in Builder at line 402
protected array createSub(Closure|Builder|Builder|Relation|string $query)

Creates a subquery and parse it.

Parameters

Closure|Builder|Builder|Relation|string $query

Return Value

array

in Builder at line 421
protected array parseSub(mixed $query)

Parse the subquery into SQL and bindings.

Parameters

mixed $query

Return Value

array

Exceptions

InvalidArgumentException

in Builder at line 449
protected Builder prependDatabaseNameIfCrossDatabaseQuery(Builder $query)

Prepend the database name if the given query is on another database.

Parameters

Builder $query

Return Value

Builder

in Builder at line 470
Builder addSelect(mixed $column)

Add a new select column to the query.

Parameters

mixed $column

Return Value

Builder

in Builder at line 498
string getDefaultSelectColumn()

Get the wildcard selection for the query's primary source.

Return Value

string

Exceptions

InvalidArgumentException

in Builder at line 519
Builder selectVectorDistance(Expression|string $column, Collection|Arrayable|array|string $vector, string|null $as = null)

Add a vector-similarity selection to the query.

Parameters

Expression|string $column
Collection|Arrayable|array|string $vector
string|null $as

Return Value

Builder

Exceptions

JsonException

in Builder at line 552
Builder distinct()

Force the query to only return distinct results.

Return Value

Builder

in Builder at line 571
Builder from(Closure|Builder|Builder|Relation|Expression|string $table, string|null $as = null)

Set the table which the query is targeting.

Parameters

Closure|Builder|Builder|Relation|Expression|string $table
string|null $as

Return Value

Builder

in Builder at line 593
string|null getFromAlias()

Get the alias or table name that qualifies the query's source columns.

Raw sources without an explicit alias return null; raw SQL is not parsed.

Return Value

string|null

in Builder at line 603
Builder useIndex(string $index)

Add an index hint to suggest a query index.

Parameters

string $index

Return Value

Builder

in Builder at line 615
Builder forceIndex(string $index)

Add an index hint to force a query index.

Parameters

string $index

Return Value

Builder

in Builder at line 627
Builder ignoreIndex(string $index)

Add an index hint to ignore a query index.

Parameters

string $index

Return Value

Builder

in Builder at line 639
Builder join(Expression|string $table, Closure|Expression|string $first, Expression|string|null $operator = null, mixed $second = null, string $type = 'inner', bool $where = false)

Add a "join" clause to the query.

Parameters

Expression|string $table
Closure|Expression|string $first
Expression|string|null $operator
mixed $second
string $type
bool $where

Return Value

Builder

in Builder at line 673
Builder joinWhere(Expression|string $table, Closure|Expression|string $first, string $operator, mixed $second, string $type = 'inner')

Add a "join where" clause to the query.

Parameters

Expression|string $table
Closure|Expression|string $first
string $operator
mixed $second
string $type

Return Value

Builder

in Builder at line 686
Builder joinSub(Closure|Builder|Builder|Relation|string $query, string $as, Closure|Expression|string $first, Expression|string|null $operator = null, mixed $second = null, string $type = 'inner', bool $where = false)

Add a "subquery join" clause to the query.

Parameters

Closure|Builder|Builder|Relation|string $query
string $as
Closure|Expression|string $first
Expression|string|null $operator
mixed $second
string $type
bool $where

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 708
Builder joinLateral(Closure|Builder|Builder|Relation|string $query, string $as, string $type = 'inner')

Add a "lateral join" clause to the query.

Parameters

Closure|Builder|Builder|Relation|string $query
string $as
string $type

Return Value

Builder

in Builder at line 727
Builder leftJoinLateral(Closure|Builder|Builder|Relation|string $query, string $as)

Add a lateral left join to the query.

Parameters

Closure|Builder|Builder|Relation|string $query
string $as

Return Value

Builder

in Builder at line 737
Builder leftJoin(Expression|string $table, Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null)

Add a left join to the query.

Parameters

Expression|string $table
Closure|Expression|string $first
Expression|string|null $operator
Expression|string|null $second

Return Value

Builder

in Builder at line 747
Builder leftJoinWhere(Expression|string $table, Closure|Expression|string $first, string $operator, mixed $second)

Add a "join where" clause to the query.

Parameters

Expression|string $table
Closure|Expression|string $first
string $operator
mixed $second

Return Value

Builder

in Builder at line 758
Builder leftJoinSub(Closure|Builder|Builder|Relation|string $query, string $as, Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null)

Add a subquery left join to the query.

Parameters

Closure|Builder|Builder|Relation|string $query
string $as
Closure|Expression|string $first
Expression|string|null $operator
Expression|string|null $second

Return Value

Builder

in Builder at line 768
Builder rightJoin(Expression|string $table, Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null)

Add a right join to the query.

Parameters

Expression|string $table
Closure|Expression|string $first
Expression|string|null $operator
Expression|string|null $second

Return Value

Builder

in Builder at line 778
Builder rightJoinWhere(Expression|string $table, Closure|Expression|string $first, string $operator, mixed $second)

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

Parameters

Expression|string $table
Closure|Expression|string $first
string $operator
mixed $second

Return Value

Builder

in Builder at line 789
Builder rightJoinSub(Closure|Builder|Builder|Relation|string $query, string $as, Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null)

Add a subquery right join to the query.

Parameters

Closure|Builder|Builder|Relation|string $query
string $as
Closure|Expression|string $first
Expression|string|null $operator
Expression|string|null $second

Return Value

Builder

in Builder at line 799
Builder crossJoin(Expression|string $table, Closure|Expression|string|null $first = null, Expression|string|null $operator = null, Expression|string|null $second = null)

Add a "cross join" clause to the query.

Parameters

Expression|string $table
Closure|Expression|string|null $first
Expression|string|null $operator
Expression|string|null $second

Return Value

Builder

in Builder at line 816
Builder crossJoinSub(Closure|Builder|Builder|Relation|string $query, string $as)

Add a subquery cross join to the query.

Parameters

Closure|Builder|Builder|Relation|string $query
string $as

Return Value

Builder

in Builder at line 834
Builder straightJoin(Expression|string $table, Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null)

Add a straight join to the query.

Parameters

Expression|string $table
Closure|Expression|string $first
Expression|string|null $operator
Expression|string|null $second

Return Value

Builder

in Builder at line 844
Builder straightJoinWhere(Expression|string $table, Closure|Expression|string $first, string $operator, mixed $second)

Add a straight join where clause to the query.

Parameters

Expression|string $table
Closure|Expression|string $first
string $operator
mixed $second

Return Value

Builder

in Builder at line 855
Builder straightJoinSub(Closure|Builder|Builder|Relation|string $query, string $as, Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null)

Add a subquery straight join to the query.

Parameters

Closure|Builder|Builder|Relation|string $query
string $as
Closure|Expression|string $first
Expression|string|null $operator
Expression|string|null $second

Return Value

Builder

in Builder at line 863
protected JoinClause newJoinClause(Builder $parentQuery, string $type, Expression|string $table)

Get a new "join" clause.

Parameters

Builder $parentQuery
string $type
Expression|string $table

Return Value

JoinClause

in Builder at line 871
protected JoinLateralClause newJoinLateralClause(Builder $parentQuery, string $type, Expression|string $table)

Get a new "join lateral" clause.

Parameters

Builder $parentQuery
string $type
Expression|string $table

Return Value

JoinLateralClause

in Builder at line 881
Builder mergeWheres(array $wheres, array $bindings)

Merge an array of "where" clauses and bindings.

Parameters

array $wheres
array $bindings

Return Value

Builder

in Builder at line 897
Builder where(Closure|Builder|Builder|Relation|Expression|array|string $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Add a basic "where" clause to the query.

Parameters

Closure|Builder|Builder|Relation|Expression|array|string $column
mixed $operator
mixed $value
string $boolean

Return Value

Builder

in Builder at line 1006
protected Builder addArrayOfWheres(array $column, string $boolean, string $method = 'where')

Add an array of "where" clauses to the query.

Parameters

array $column
string $boolean
string $method

Return Value

Builder

in Builder at line 1024
array prepareValueAndOperator(mixed $value, mixed $operator, bool $useDefault = false)

Prepare the value and operator for a where clause.

Parameters

mixed $value
mixed $operator
bool $useDefault

Return Value

array

Exceptions

InvalidArgumentException

in Builder at line 1041
protected bool invalidOperatorAndValue(mixed $operator, mixed $value)

Determine if the given operator and value combination is legal.

Prevents using Null values with invalid operators.

Parameters

mixed $operator
mixed $value

Return Value

bool

in Builder at line 1050
protected bool invalidOperator(mixed $operator)

Determine if the given operator is supported.

Parameters

mixed $operator

Return Value

bool

in Builder at line 1059
protected bool isBitwiseOperator(string $operator)

Determine if the operator is a bitwise operator.

Parameters

string $operator

Return Value

bool

in Builder at line 1070
Builder orWhere(Closure|Builder|Builder|Relation|Expression|array|string $column, mixed $operator = null, mixed $value = null)

Add an "or where" clause to the query.

Parameters

Closure|Builder|Builder|Relation|Expression|array|string $column
mixed $operator
mixed $value

Return Value

Builder

in Builder at line 1086
Builder whereNot(Closure|Builder|Builder|Relation|Expression|array|string $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')

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

Parameters

Closure|Builder|Builder|Relation|Expression|array|string $column
mixed $operator
mixed $value
string $boolean

Return Value

Builder

in Builder at line 1102
Builder orWhereNot(Closure|Builder|Builder|Relation|Expression|array|string $column, mixed $operator = null, mixed $value = null)

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

Parameters

Closure|Builder|Builder|Relation|Expression|array|string $column
mixed $operator
mixed $value

Return Value

Builder

in Builder at line 1112
Builder whereColumn(Expression|string|array $first, Expression|string|null $operator = null, Expression|string|null $second = null, string $boolean = 'and')

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

Parameters

Expression|string|array $first
Expression|string|null $operator
Expression|string|null $second
string $boolean

Return Value

Builder

in Builder at line 1145
Builder orWhereColumn(Expression|string|array $first, Expression|string|null $operator = null, Expression|string|null $second = null)

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

Parameters

Expression|string|array $first
Expression|string|null $operator
Expression|string|null $second

Return Value

Builder

in Builder at line 1159
Builder whereVectorSimilarTo(Expression|string $column, Collection|Arrayable|array|string $vector, float $minSimilarity = 0.6, bool $order = true)

Add a vector similarity clause to the query, filtering by minimum similarity and ordering by similarity.

Parameters

Expression|string $column
Collection|Arrayable|array|string $vector
float $minSimilarity

A value between 0.0 and 1.0, where 1.0 is identical.

bool $order

Return Value

Builder

Exceptions

JsonException

in Builder at line 1184
Builder whereVectorDistanceLessThan(Expression|string $column, Collection|Arrayable|array|string $vector, float $maxDistance, string $boolean = 'and')

Add a vector distance "where" clause to the query.

Parameters

Expression|string $column
Collection|Arrayable|array|string $vector
float $maxDistance
string $boolean

Return Value

Builder

Exceptions

JsonException

in Builder at line 1215
Builder orWhereVectorDistanceLessThan(Expression|string $column, Collection|Arrayable|array|string $vector, float $maxDistance)

Add a vector distance "or where" clause to the query.

Parameters

Expression|string $column
Collection|Arrayable|array|string $vector
float $maxDistance

Return Value

Builder

Exceptions

JsonException

in Builder at line 1225
Builder whereRaw(Expression|string $sql, mixed $bindings = [], string $boolean = 'and')

Add a raw "where" clause to the query.

Parameters

Expression|string $sql
mixed $bindings
string $boolean

Return Value

Builder

in Builder at line 1239
Builder orWhereRaw(string $sql, mixed $bindings = [])

Add a raw "or where" clause to the query.

Parameters

string $sql
mixed $bindings

Return Value

Builder

in Builder at line 1249
Builder whereBinary(Expression|string $column, string $value, string $boolean = 'and', bool $not = false)

Add a "where binary" clause to the query.

Parameters

Expression|string $column
string $value
string $boolean
bool $not

Return Value

Builder

in Builder at line 1265
Builder orWhereBinary(Expression|string $column, string $value)

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

Parameters

Expression|string $column
string $value

Return Value

Builder

in Builder at line 1275
Builder whereNotBinary(Expression|string $column, string $value, string $boolean = 'and')

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

Parameters

Expression|string $column
string $value
string $boolean

Return Value

Builder

in Builder at line 1285
Builder orWhereNotBinary(Expression|string $column, string $value)

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

Parameters

Expression|string $column
string $value

Return Value

Builder

in Builder at line 1295
Builder whereLike(Expression|string $column, string $value, bool $caseSensitive = false, string $boolean = 'and', bool $not = false)

Add a "where like" clause to the query.

Parameters

Expression|string $column
string $value
bool $caseSensitive
string $boolean
bool $not

Return Value

Builder

in Builder at line 1315
Builder orWhereLike(Expression|string $column, string $value, bool $caseSensitive = false)

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

Parameters

Expression|string $column
string $value
bool $caseSensitive

Return Value

Builder

in Builder at line 1325
Builder whereNotLike(Expression|string $column, string $value, bool $caseSensitive = false, string $boolean = 'and')

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

Parameters

Expression|string $column
string $value
bool $caseSensitive
string $boolean

Return Value

Builder

in Builder at line 1335
Builder orWhereNotLike(Expression|string $column, string $value, bool $caseSensitive = false)

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

Parameters

Expression|string $column
string $value
bool $caseSensitive

Return Value

Builder

in Builder at line 1345
Builder whereNullSafeEquals(Expression|string $column, mixed $value, string $boolean = 'and')

Add a null-safe equality clause to the query.

Parameters

Expression|string $column
mixed $value
string $boolean

Return Value

Builder

in Builder at line 1367
Builder orWhereNullSafeEquals(Expression|string $column, mixed $value)

Add an "or" null-safe equality clause to the query.

Parameters

Expression|string $column
mixed $value

Return Value

Builder

in Builder at line 1379
Builder whereIn(Expression|string $column, mixed $values, string $boolean = 'and', bool $not = false)

Add a "where in" clause to the query.

Parameters

Expression|string $column
mixed $values
string $boolean
bool $not

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 1420
Builder orWhereIn(Expression|string $column, mixed $values)

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

Parameters

Expression|string $column
mixed $values

Return Value

Builder

in Builder at line 1430
Builder whereNotIn(Expression|string $column, mixed $values, string $boolean = 'and')

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

Parameters

Expression|string $column
mixed $values
string $boolean

Return Value

Builder

in Builder at line 1440
Builder orWhereNotIn(Expression|string $column, mixed $values)

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

Parameters

Expression|string $column
mixed $values

Return Value

Builder

in Builder at line 1450
Builder whereIntegerInRaw(string $column, Arrayable|array $values, string $boolean = 'and', bool $not = false)

Add a "where in raw" clause for integer values to the query.

Parameters

string $column
Arrayable|array $values
string $boolean
bool $not

Return Value

Builder

in Builder at line 1474
Builder orWhereIntegerInRaw(string $column, Arrayable|array $values)

Add an "or where in raw" clause for integer values to the query.

Parameters

string $column
Arrayable|array $values

Return Value

Builder

in Builder at line 1484
Builder whereIntegerNotInRaw(string $column, Arrayable|array $values, string $boolean = 'and')

Add a "where not in raw" clause for integer values to the query.

Parameters

string $column
Arrayable|array $values
string $boolean

Return Value

Builder

in Builder at line 1494
Builder orWhereIntegerNotInRaw(string $column, Arrayable|array $values)

Add an "or where not in raw" clause for integer values to the query.

Parameters

string $column
Arrayable|array $values

Return Value

Builder

in Builder at line 1504
Builder whereNull(string|array|Expression $columns, string $boolean = 'and', bool $not = false)

Add a "where null" clause to the query.

Parameters

string|array|Expression $columns
string $boolean
bool $not

Return Value

Builder

in Builder at line 1520
Builder orWhereNull(string|array|Expression $column)

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

Parameters

string|array|Expression $column

Return Value

Builder

in Builder at line 1530
Builder whereNotNull(string|array|Expression $columns, string $boolean = 'and')

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

Parameters

string|array|Expression $columns
string $boolean

Return Value

Builder

in Builder at line 1541
Builder whereBetween(Closure|Builder|Builder|Relation|Expression|string $column, iterable $values, string $boolean = 'and', bool $not = false)

Add a "where between" statement to the query.

Parameters

Closure|Builder|Builder|Relation|Expression|string $column
iterable $values
string $boolean
bool $not

Return Value

Builder

in Builder at line 1571
Builder whereBetweenColumns(Closure|Builder|Builder|Relation|Expression|string $column, array $values, string $boolean = 'and', bool $not = false)

Add a "where between" statement using columns to the query.

Parameters

Closure|Builder|Builder|Relation|Expression|string $column
array $values
string $boolean
bool $not

Return Value

Builder

in Builder at line 1593
Builder orWhereBetween(Closure|Builder|Builder|Relation|Expression|string $column, iterable $values)

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

Parameters

Closure|Builder|Builder|Relation|Expression|string $column
iterable $values

Return Value

Builder

in Builder at line 1603
Builder orWhereBetweenColumns(Closure|Builder|Builder|Relation|Expression|string $column, array $values)

Add an "or where between" statement using columns to the query.

Parameters

Closure|Builder|Builder|Relation|Expression|string $column
array $values

Return Value

Builder

in Builder at line 1614
Builder whereNotBetween(Closure|Builder|Builder|Relation|Expression|string $column, iterable $values, string $boolean = 'and')

Add a "where not between" statement to the query.

Parameters

Closure|Builder|Builder|Relation|Expression|string $column
iterable $values
string $boolean

Return Value

Builder

in Builder at line 1624
Builder whereNotBetweenColumns(Closure|Builder|Builder|Relation|Expression|string $column, array $values, string $boolean = 'and')

Add a "where not between" statement using columns to the query.

Parameters

Closure|Builder|Builder|Relation|Expression|string $column
array $values
string $boolean

Return Value

Builder

in Builder at line 1635
Builder orWhereNotBetween(Closure|Builder|Builder|Relation|Expression|string $column, iterable $values)

Add an "or where not between" statement to the query.

Parameters

Closure|Builder|Builder|Relation|Expression|string $column
iterable $values

Return Value

Builder

in Builder at line 1645
Builder orWhereNotBetweenColumns(Closure|Builder|Builder|Relation|Expression|string $column, array $values)

Add an "or where not between" statement using columns to the query.

Parameters

Closure|Builder|Builder|Relation|Expression|string $column
array $values

Return Value

Builder

in Builder at line 1656
Builder whereValueBetween(mixed $value, array $columns, string $boolean = 'and', bool $not = false)

Add a "where between columns" statement using a value to the query.

Parameters

mixed $value
array $columns
string $boolean
bool $not

Return Value

Builder

in Builder at line 1676
Builder orWhereValueBetween(mixed $value, array $columns)

Add an "or where between columns" statement using a value to the query.

Parameters

mixed $value
array $columns

Return Value

Builder

in Builder at line 1687
Builder whereValueNotBetween(mixed $value, array $columns, string $boolean = 'and')

Add a "where not between columns" statement using a value to the query.

Parameters

mixed $value
array $columns
string $boolean

Return Value

Builder

in Builder at line 1698
Builder orWhereValueNotBetween(mixed $value, array $columns)

Add an "or where not between columns" statement using a value to the query.

Parameters

mixed $value
array $columns

Return Value

Builder

in Builder at line 1708
Builder orWhereNotNull(array|Expression|string $column)

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

Parameters

array|Expression|string $column

Return Value

Builder

in Builder at line 1718
Builder whereDate(Expression|Stringable|string $column, mixed $operator, mixed $value = null, string $boolean = 'and')

Add a "where date" statement to the query.

Parameters

Expression|Stringable|string $column
mixed $operator
mixed $value
string $boolean

Return Value

Builder

in Builder at line 1747
Builder orWhereDate(Expression|Stringable|string $column, mixed $operator, mixed $value = null)

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

Parameters

Expression|Stringable|string $column
mixed $operator
mixed $value

Return Value

Builder

in Builder at line 1763
Builder whereTime(Expression|Stringable|string $column, mixed $operator, mixed $value = null, string $boolean = 'and')

Add a "where time" statement to the query.

Parameters

Expression|Stringable|string $column
mixed $operator
mixed $value
string $boolean

Return Value

Builder

in Builder at line 1792
Builder orWhereTime(Expression|Stringable|string $column, mixed $operator, mixed $value = null)

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

Parameters

Expression|Stringable|string $column
mixed $operator
mixed $value

Return Value

Builder

in Builder at line 1808
Builder whereDay(Expression|Stringable|string $column, mixed $operator, mixed $value = null, string $boolean = 'and')

Add a "where day" statement to the query.

Parameters

Expression|Stringable|string $column
mixed $operator
mixed $value
string $boolean

Return Value

Builder

in Builder at line 1842
Builder orWhereDay(Expression|Stringable|string $column, mixed $operator, mixed $value = null)

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

Parameters

Expression|Stringable|string $column
mixed $operator
mixed $value

Return Value

Builder

in Builder at line 1858
Builder whereMonth(Expression|Stringable|string $column, mixed $operator, mixed $value = null, string $boolean = 'and')

Add a "where month" statement to the query.

Parameters

Expression|Stringable|string $column
mixed $operator
mixed $value
string $boolean

Return Value

Builder

in Builder at line 1892
Builder orWhereMonth(Expression|Stringable|string $column, mixed $operator, mixed $value = null)

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

Parameters

Expression|Stringable|string $column
mixed $operator
mixed $value

Return Value

Builder

in Builder at line 1908
Builder whereYear(Expression|Stringable|string $column, mixed $operator, mixed $value = null, string $boolean = 'and')

Add a "where year" statement to the query.

Parameters

Expression|Stringable|string $column
mixed $operator
mixed $value
string $boolean

Return Value

Builder

in Builder at line 1937
Builder orWhereYear(Expression|Stringable|string $column, mixed $operator, mixed $value = null)

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

Parameters

Expression|Stringable|string $column
mixed $operator
mixed $value

Return Value

Builder

in Builder at line 1953
protected Builder addDateBasedWhere(string $type, Expression|Stringable|string $column, string $operator, mixed $value, string $boolean = 'and')

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

Parameters

string $type
Expression|Stringable|string $column
string $operator
mixed $value
string $boolean

Return Value

Builder

in Builder at line 1972
Builder whereNested(Closure $callback, string $boolean = 'and')

Add a nested "where" statement to the query.

Parameters

Closure $callback
string $boolean

Return Value

Builder

in Builder at line 1982
Builder forNestedWhere()

Create a new query instance for nested where condition.

Return Value

Builder

in Builder at line 1998
Builder addNestedWhereQuery(Builder $query, string $boolean = 'and')

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

Parameters

Builder $query
string $boolean

Return Value

Builder

in Builder at line 2019
protected Builder whereSub(Expression|string $column, string $operator, Closure|Builder|Builder|Relation $callback, string $boolean)

Add a full sub-select to the query.

Parameters

Expression|string $column
string $operator
Closure|Builder|Builder|Relation $callback
string $boolean

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 2051
Builder whereExists(Closure|Builder|Builder $callback, string $boolean = 'and', bool $not = false)

Add an "exists" clause to the query.

Parameters

Closure|Builder|Builder $callback
string $boolean
bool $not

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 2075
Builder orWhereExists(Closure|Builder|Builder $callback, bool $not = false)

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

Parameters

Closure|Builder|Builder $callback
bool $not

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 2088
Builder whereNotExists(Closure|Builder|Builder $callback, string $boolean = 'and')

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

Parameters

Closure|Builder|Builder $callback
string $boolean

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 2101
Builder orWhereNotExists(Closure|Builder|Builder $callback)

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

Parameters

Closure|Builder|Builder $callback

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 2113
Builder addWhereExistsQuery(Builder $query, string $boolean = 'and', bool $not = false)

Add an "exists" clause to the query.

Parameters

Builder $query
string $boolean
bool $not

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 2133
Builder whereRowValues(array $columns, string $operator, array $values, string $boolean = 'and')

Add a where condition using row values.

Parameters

array $columns
string $operator
array $values
string $boolean

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 2157
Builder orWhereRowValues(array $columns, string $operator, array $values)

Adds an or where condition using row values.

Parameters

array $columns
string $operator
array $values

Return Value

Builder

in Builder at line 2167
Builder whereJsonContains(string $column, mixed $value, string $boolean = 'and', bool $not = false)

Add a "where JSON contains" clause to the query.

Parameters

string $column
mixed $value
string $boolean
bool $not

Return Value

Builder

in Builder at line 2185
Builder orWhereJsonContains(string $column, mixed $value)

Add an "or where JSON contains" clause to the query.

Parameters

string $column
mixed $value

Return Value

Builder

in Builder at line 2195
Builder whereJsonDoesntContain(string $column, mixed $value, string $boolean = 'and')

Add a "where JSON not contains" clause to the query.

Parameters

string $column
mixed $value
string $boolean

Return Value

Builder

in Builder at line 2205
Builder orWhereJsonDoesntContain(string $column, mixed $value)

Add an "or where JSON not contains" clause to the query.

Parameters

string $column
mixed $value

Return Value

Builder

in Builder at line 2215
Builder whereJsonOverlaps(string $column, mixed $value, string $boolean = 'and', bool $not = false)

Add a "where JSON overlaps" clause to the query.

Parameters

string $column
mixed $value
string $boolean
bool $not

Return Value

Builder

in Builder at line 2233
Builder orWhereJsonOverlaps(string $column, mixed $value)

Add an "or where JSON overlaps" clause to the query.

Parameters

string $column
mixed $value

Return Value

Builder

in Builder at line 2243
Builder whereJsonDoesntOverlap(string $column, mixed $value, string $boolean = 'and')

Add a "where JSON not overlap" clause to the query.

Parameters

string $column
mixed $value
string $boolean

Return Value

Builder

in Builder at line 2253
Builder orWhereJsonDoesntOverlap(string $column, mixed $value)

Add an "or where JSON not overlap" clause to the query.

Parameters

string $column
mixed $value

Return Value

Builder

in Builder at line 2263
Builder whereJsonContainsKey(string $column, string $boolean = 'and', bool $not = false)

Add a clause that determines if a JSON path exists to the query.

Parameters

string $column
string $boolean
bool $not

Return Value

Builder

in Builder at line 2277
Builder orWhereJsonContainsKey(string $column)

Add an "or" clause that determines if a JSON path exists to the query.

Parameters

string $column

Return Value

Builder

in Builder at line 2287
Builder whereJsonDoesntContainKey(string $column, string $boolean = 'and')

Add a clause that determines if a JSON path does not exist to the query.

Parameters

string $column
string $boolean

Return Value

Builder

in Builder at line 2297
Builder orWhereJsonDoesntContainKey(string $column)

Add an "or" clause that determines if a JSON path does not exist to the query.

Parameters

string $column

Return Value

Builder

in Builder at line 2307
Builder whereJsonLength(string $column, mixed $operator, mixed $value = null, string $boolean = 'and')

Add a "where JSON length" clause to the query.

Parameters

string $column
mixed $operator
mixed $value
string $boolean

Return Value

Builder

in Builder at line 2338
Builder orWhereJsonLength(string $column, mixed $operator, mixed $value = null)

Add an "or where JSON length" clause to the query.

Parameters

string $column
mixed $operator
mixed $value

Return Value

Builder

in Builder at line 2354
Builder dynamicWhere(string $method, array $parameters)

Handles dynamic "where" clauses to the query.

Parameters

string $method
array $parameters

Return Value

Builder

in Builder at line 2396
protected void addDynamic(string $segment, string $connector, array $parameters, int $index)

Add a single dynamic "where" clause statement to the query.

Parameters

string $segment
string $connector
array $parameters
int $index

Return Value

void

in Builder at line 2411
Builder whereFullText(string|array $columns, string $value, array $options = [], string $boolean = 'and')

Add a "where fulltext" clause to the query.

Parameters

string|array $columns
string $value
array $options
string $boolean

Return Value

Builder

in Builder at line 2429
Builder orWhereFullText(string|array $columns, string $value, array $options = [])

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

Parameters

string|array $columns
string $value
array $options

Return Value

Builder

in Builder at line 2440
Builder whereAll(array $columns, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Add a "where" clause to the query for multiple columns with "and" conditions between them.

Parameters

array $columns
mixed $operator
mixed $value
string $boolean

Return Value

Builder

in Builder at line 2463
Builder orWhereAll(array $columns, mixed $operator = null, mixed $value = null)

Add an "or where" clause to the query for multiple columns with "and" conditions between them.

Parameters

array $columns
mixed $operator
mixed $value

Return Value

Builder

in Builder at line 2474
Builder whereAny(array $columns, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Add a "where" clause to the query for multiple columns with "or" conditions between them.

Parameters

array $columns
mixed $operator
mixed $value
string $boolean

Return Value

Builder

in Builder at line 2497
Builder orWhereAny(array $columns, mixed $operator = null, mixed $value = null)

Add an "or where" clause to the query for multiple columns with "or" conditions between them.

Parameters

array $columns
mixed $operator
mixed $value

Return Value

Builder

in Builder at line 2508
Builder whereNone(array $columns, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Add a "where not" clause to the query for multiple columns where none of the conditions should be true.

Parameters

array $columns
mixed $operator
mixed $value
string $boolean

Return Value

Builder

in Builder at line 2519
Builder orWhereNone(array $columns, mixed $operator = null, mixed $value = null)

Add an "or where not" clause to the query for multiple columns where none of the conditions should be true.

Parameters

array $columns
mixed $operator
mixed $value

Return Value

Builder

in Builder at line 2529
Builder groupBy(array|Expression|string ...$groups)

Add a "group by" clause to the query.

Parameters

array|Expression|string ...$groups

Return Value

Builder

in Builder at line 2546
Builder groupByRaw(string $sql, array $bindings = [])

Add a raw "groupBy" clause to the query.

Parameters

string $sql
array $bindings

Return Value

Builder

in Builder at line 2560
Builder having(Expression|Closure|string $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')

Add a "having" clause to the query.

Parameters

Expression|Closure|string $column
mixed $operator
mixed $value
string $boolean

Return Value

Builder

in Builder at line 2614
Builder orHaving(Expression|Closure|string $column, mixed $operator = null, mixed $value = null)

Add an "or having" clause to the query.

Parameters

Expression|Closure|string $column
mixed $operator
mixed $value

Return Value

Builder

in Builder at line 2633
Builder havingNested(Closure $callback, string $boolean = 'and')

Add a nested "having" statement to the query.

Parameters

Closure $callback
string $boolean

Return Value

Builder

in Builder at line 2645
Builder addNestedHavingQuery(Builder $query, string $boolean = 'and')

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

Parameters

Builder $query
string $boolean

Return Value

Builder

in Builder at line 2663
Builder havingNull(array|string $columns, string $boolean = 'and', bool $not = false)

Add a "having null" clause to the query.

Parameters

array|string $columns
string $boolean
bool $not

Return Value

Builder

in Builder at line 2679
Builder orHavingNull(string $column)

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

Parameters

string $column

Return Value

Builder

in Builder at line 2689
Builder havingNotNull(array|string $columns, string $boolean = 'and')

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

Parameters

array|string $columns
string $boolean

Return Value

Builder

in Builder at line 2699
Builder orHavingNotNull(string $column)

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

Parameters

string $column

Return Value

Builder

in Builder at line 2709
Builder havingBetween(string $column, iterable $values, string $boolean = 'and', bool $not = false)

Add a "having between" clause to the query.

Parameters

string $column
iterable $values
string $boolean
bool $not

Return Value

Builder

in Builder at line 2731
Builder havingNotBetween(string $column, iterable $values, string $boolean = 'and')

Add a "having not between" clause to the query.

Parameters

string $column
iterable $values
string $boolean

Return Value

Builder

in Builder at line 2741
Builder orHavingBetween(string $column, iterable $values)

Add an "or having between" clause to the query.

Parameters

string $column
iterable $values

Return Value

Builder

in Builder at line 2751
Builder orHavingNotBetween(string $column, iterable $values)

Add an "or having not between" clause to the query.

Parameters

string $column
iterable $values

Return Value

Builder

in Builder at line 2761
protected array resolveDatePeriodBounds(DatePeriod $period)

Resolve the start and end dates from a DatePeriod.

Parameters

DatePeriod $period

Return Value

array

in Builder at line 2782
Builder havingRaw(string $sql, array $bindings = [], string $boolean = 'and')

Add a raw "having" clause to the query.

Parameters

string $sql
array $bindings
string $boolean

Return Value

Builder

in Builder at line 2798
Builder orHavingRaw(string $sql, array $bindings = [])

Add a raw "or having" clause to the query.

Parameters

string $sql
array $bindings

Return Value

Builder

in Builder at line 2812
Builder orderBy(Closure|Builder|Builder|Relation|Expression|string $column, SortDirection|string $direction = SortDirection::Ascending)

Add an "order by" clause to the query.

Parameters

Closure|Builder|Builder|Relation|Expression|string $column
SortDirection|string $direction

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 2846
Builder orderByDesc(Closure|Builder|Builder|Relation|Expression|string $column)

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

Parameters

Closure|Builder|Builder|Relation|Expression|string $column

Return Value

Builder

in Builder at line 2856
Builder latest(Closure|Builder|Builder|Relation|Expression|string $column = 'created_at')

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

Parameters

Closure|Builder|Builder|Relation|Expression|string $column

Return Value

Builder

in Builder at line 2866
Builder oldest(Closure|Builder|Builder|Relation|Expression|string $column = 'created_at')

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

Parameters

Closure|Builder|Builder|Relation|Expression|string $column

Return Value

Builder

in Builder at line 2879
Builder orderByVectorDistance(Expression|string $column, Collection|Arrayable|array|string $vector)

Add a vector-distance "order by" clause to the query.

Parameters

Expression|string $column
Collection|Arrayable|array|string $vector

Return Value

Builder

Exceptions

JsonException

in Builder at line 2910
Builder inRandomOrder(string|int $seed = '')

Put the query's results in random order.

Parameters

string|int $seed

Return Value

Builder

in Builder at line 2921
Builder inOrderOf(Expression|string $column, Arrayable|array $values)

Add an "order by" clause to order results by a given sequence of values.

Parameters

Expression|string $column
Arrayable|array $values

Return Value

Builder

in Builder at line 2951
Builder orderByRaw(string $sql, mixed $bindings = [])

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

Parameters

string $sql
mixed $bindings

Return Value

Builder

in Builder at line 2965
protected void addOrderBindings(array $bindings)

Attach bindings to the last column order so removing it also removes its parameters.

Parameters

array $bindings

Return Value

void

in Builder at line 2987
Builder skip(int|null $value)

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

Parameters

int|null $value

Return Value

Builder

in Builder at line 2997
Builder offset(int|null $value)

Set the "offset" value of the query.

Parameters

int|null $value

Return Value

Builder

in Builder at line 3011
Builder take(int|null $value)

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

Parameters

int|null $value

Return Value

Builder

in Builder at line 3021
Builder limit(int|null $value)

Set the "limit" value of the query.

Parameters

int|null $value

Return Value

Builder

in Builder at line 3037
Builder groupLimit(int $value, string $column)

Add a "group limit" clause to the query.

Parameters

int $value
string $column

Return Value

Builder

in Builder at line 3051
Builder forPage(int $page, int $perPage = 15)

Set the limit and offset for a given page.

Parameters

int $page
int $perPage

Return Value

Builder

in Builder at line 3062
Builder forPageBeforeId(int $perPage = 15, mixed $lastId = 0, string $column = 'id')

Constrain the query to the previous "page" of results before a given ID.

Parameters

int $perPage
mixed $lastId
string $column

Return Value

Builder

in Builder at line 3096
Builder forPageAfterId(int $perPage = 15, mixed $lastId = 0, string $column = 'id')

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

Parameters

int $perPage
mixed $lastId
string $column

Return Value

Builder

in Builder at line 3130
Builder reorder(Closure|Builder|Builder|Relation|Expression|string|null $column = null, SortDirection|string $direction = SortDirection::Ascending)

Remove all existing orders and optionally add a new order.

Parameters

Closure|Builder|Builder|Relation|Expression|string|null $column
SortDirection|string $direction

Return Value

Builder

in Builder at line 3150
Builder reorderDesc(Closure|Builder|Builder|Relation|Expression|string|null $column)

Add descending "reorder" clause to the query.

Parameters

Closure|Builder|Builder|Relation|Expression|string|null $column

Return Value

Builder

in Builder at line 3158
protected array removeExistingOrdersFor(string $column)

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

Parameters

string $column

Return Value

array

in Builder at line 3166
protected array removeOrdersFor(array $orders, array $bindings, string $column)

Remove matching orders and only their owned parameters.

Parameters

array $orders
array $bindings
string $column

Return Value

array

in Builder at line 3215
Builder union(Closure|Builder|Builder $query, bool $all = false)

Add a "union" statement to the query.

Parameters

Closure|Builder|Builder $query
bool $all

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 3242
Builder unionAll(Closure|Builder|Builder $query)

Add a "union all" statement to the query.

Parameters

Closure|Builder|Builder $query

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 3252
Builder lock(string|bool $value = true)

Lock the selected rows in the table.

Parameters

string|bool $value

Return Value

Builder

in Builder at line 3269
Builder lockForUpdate()

Lock the selected rows in the table for updating.

Return Value

Builder

in Builder at line 3279
Builder sharedLock()

Share lock the selected rows in the table.

Return Value

Builder

in Builder at line 3289
Builder skipLocked()

Skip rows locked by another transaction when supported by the server.

Return Value

Builder

in Builder at line 3307
Builder timeout(int|null $seconds)

Set a query execution timeout in seconds.

Parameters

int|null $seconds

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 3323
Builder beforeQuery(callable $callback)

Register a closure to be invoked before the query is executed.

Parameters

callable $callback

Return Value

Builder

in Builder at line 3333
void applyBeforeQueryCallbacks()

Invoke the "before query" modification callbacks.

Return Value

void

in Builder at line 3348
Builder afterQuery(Closure $callback)

Register a closure to be invoked after the query is executed.

Parameters

Closure $callback

Return Value

Builder

in Builder at line 3361
Collection applyAfterQueryCallbacks(Collection $result)

Invoke the "after query" modification callbacks.

Parameters

Collection $result

Return Value

Collection

in Builder at line 3373
string toSql()

Get the SQL representation of the query.

Return Value

string

in Builder at line 3383
string toRawSql()

Get the raw SQL representation of the query with embedded bindings.

Return Value

string

in Builder at line 3397
mixed find(int|string $id, Expression|array|string $columns = ['*'])

Execute a query for a single record by ID.

Parameters

int|string $id
Expression|array|string $columns

Return Value

mixed

in Builder at line 3411
mixed findOr(mixed $id, Closure|Expression|array|string $columns = ['*'], Closure|null $callback = null)

Execute a query for a single record by ID or call a callback.

Parameters

mixed $id
Closure|Expression|array|string $columns
Closure|null $callback

Return Value

mixed

in Builder at line 3432
mixed value(Expression|string $column)

Get a single column's value from the first result of a query.

Parameters

Expression|string $column

Return Value

mixed

in Builder at line 3444
mixed rawValue(string $expression, array $bindings = [])

Get a single expression value from the first result of a query.

Parameters

string $expression
array $bindings

Return Value

mixed

in Builder at line 3459
mixed soleValue(Expression|string $column)

Get a single column's value from the first result of a query if it's the sole matching record.

Parameters

Expression|string $column

Return Value

mixed

Exceptions

RecordsNotFoundException
MultipleRecordsFoundException

in Builder at line 3474
Collection get(Expression|array|string $columns = ['*'])

Execute the query as a "select" statement.

Parameters

Expression|array|string $columns

Return Value

Collection

in Builder at line 3493
protected array runSelect()

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

Return Value

array

in Builder at line 3514
protected mixed withoutFetchUsing(callable $callback)

Execute the given callback without custom fetch mode arguments.

Parameters

callable $callback

Return Value

mixed

in Builder at line 3532
protected Collection withoutGroupLimitKeys(Collection $items)

Remove the group limit keys from the results in the collection.

Parameters

Collection $items

Return Value

Collection

in Builder at line 3563
LengthAwarePaginator paginate(int|Closure $perPage = 15, Expression|array|string $columns = ['*'], string $pageName = 'page', int|null $page = null, Closure|int|null $total = null)

Paginate the given query into a simple paginator.

Parameters

int|Closure $perPage
Expression|array|string $columns
string $pageName
int|null $page
Closure|int|null $total

Return Value

LengthAwarePaginator

in Builder at line 3591
Paginator simplePaginate(int $perPage = 15, Expression|array|string $columns = ['*'], string $pageName = 'page', int|null $page = null)

Get a paginator only supporting simple next and previous links.

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

Parameters

int $perPage
Expression|array|string $columns
string $pageName
int|null $page

Return Value

Paginator

in Builder at line 3614
CursorPaginator cursorPaginate(int $perPage = 15, Expression|array|string $columns = ['*'], string $cursorName = 'cursor', Cursor|string|null $cursor = null)

Get a paginator only supporting simple next and previous links.

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

Parameters

int $perPage
Expression|array|string $columns
string $cursorName
Cursor|string|null $cursor

Return Value

CursorPaginator

in Builder at line 3631
protected Collection ensureOrderForCursorPagination(bool $shouldReverse = false)

Ensure the proper order by required for cursor pagination.

Parameters

bool $shouldReverse

Return Value

Collection

in Builder at line 3666
protected void markKeysetCondition(int $offset, string|null $column = null)

Record the paging predicate and the bindings it owns.

Parameters

int $offset
string|null $column

Return Value

void

in Builder at line 3691
void prepareCursorOrdering()

internal  paging hook for framework and database-driver builders
 

Retain membership ordering before cursor traversal reverses it.

Return Value

void

in Builder at line 3714
bool restoreKeysetOrdersFrom(Builder $source)

internal  paging hook for framework and database-driver builders
 

Restore the operation's ordering when a global scope replaces its paging orders.

Parameters

Builder $source

Return Value

bool

in Builder at line 3748
Builder prioritizeKeysetOrders(bool $limited = false)

internal  
 

Sort an ID iteration by its paging column before any other order.

Parameters

bool $limited

Return Value

Builder

in Builder at line 3775
void ensureLimitedIterationOrdersById(string $column, bool $descending)

internal  
 

Reject limited ID iteration when another order would choose different rows.

Parameters

string $column
bool $descending

Return Value

void

in Builder at line 3803
Builder addCursorPaginationConditions(array $orders, array $bindings)

internal  
 

Add cursor comparisons resolved by the calling query or Eloquent builder.

Parameters

array $orders
array $bindings

Return Value

Builder

in Builder at line 3821
protected void groupOrWheresForKeyset()

Keep existing "or" conditions from bypassing the page boundary.

Return Value

void

in Builder at line 3833
protected void addCursorComparisons(array $orders, array $bindings, int $index)

Add the ordered comparisons for a compound cursor.

Parameters

array $orders
array $bindings
int $index

Return Value

void

in Builder at line 3852
protected bool requiresKeysetIsolation(bool $limitSelectsRows)

Determine whether paging must filter the result of this SELECT.

Parameters

bool $limitSelectsRows

Return Value

bool

in Builder at line 3861
protected Builder prepareForSelect()

Prepare a SELECT without changing the logical query retained by its caller.

Return Value

Builder

in Builder at line 3948
protected array collectKeysetConditions(array $wheres, array $conditions, bool $includeSelect)

Collect paging constraints without rewriting nested groups shared with another query.

Parameters

array $wheres
array $conditions
bool $includeSelect

Return Value

array

in Builder at line 3978
protected array normalizeKeysetColumns(array $where)

Normalize only framework-owned comparison columns to selected output names.

Parameters

array $where

Return Value

array

in Builder at line 3999
protected array getKeysetSelection(string $column)

Get the source column and output name of a selected entry.

Parameters

string $column

Return Value

array

in Builder at line 4020
string getKeysetOutputColumn(string $parameter, bool $source = false)

internal  
 

Get the selected output name for a paging column.

Parameters

string $parameter
bool $source

Return Value

string

in Builder at line 4046
protected string|null getKeysetSourceOutputColumn(string $column)

Find the selected output that represents a paging source column.

Parameters

string $column

Return Value

string|null

in Builder at line 4061
protected bool isSameKeysetSourceColumn(string $left, string $right)

Compare source references without conflating two explicitly qualified columns.

Parameters

string $left
string $right

Return Value

bool

in Builder at line 4070
protected string resolveKeysetOrderColumn(string $column)

Keep an ID page ordered by its WHERE source when an output alias shadows it.

Parameters

string $column

Return Value

string

in Builder at line 4098
protected void collectKeysetParameters(array $where, array $parameters)

Collect the output columns used by a compound paging constraint.

Parameters

array $where
array $parameters

Return Value

void

in Builder at line 4115
protected array mapUnionKeysetColumns(Builder $member, array $parameters)

Map union output columns only when their correspondence can be proven.

Parameters

Builder $member
array $parameters

Return Value

array

in Builder at line 4163
protected bool selectsAllSourceColumns()

Determine whether the projection selects only the source's wildcard columns.

Return Value

bool

in Builder at line 4172
protected Builder applyUnionKeysetConditions(Builder $root, array $conditions, array $parameters)

Apply inherited paging outside member bounds and through unbounded nested unions.

Parameters

Builder $root
array $conditions
array $parameters

Return Value

Builder

in Builder at line 4202
protected Builder appendKeysetConditions(array $conditions, array $mapping = [], bool $output = false)

Append comparisons using the member's source columns or isolated output names.

Parameters

array $conditions
array $mapping
bool $output

Return Value

Builder

in Builder at line 4217
protected array rebindKeysetColumns(array $where, array $mapping, bool $output)

Rebind only owned comparisons, preserving user predicates and shared nested groups.

Parameters

array $where
array $mapping
bool $output

Return Value

array

in Builder at line 4243
protected void restoreKeysetOrdering()

Restore membership ordering from live entries and the orders paging removed.

Drivers use this when their clauses select rows according to the original order.

Return Value

void

in Builder at line 4263
protected void isolateKeysetSelect(bool $limitSelectsRows)

Move row selection inside a derived table while retaining the page outside it.

Parameters

bool $limitSelectsRows

Return Value

void

in Builder at line 4299
int getCountForPagination(array $columns = ['*'])

Get the count of the total records for the paginator.

Parameters

array $columns

Return Value

int

in Builder at line 4332
protected array runPaginationCountQuery(array $columns = ['*'])

Run a pagination count query.

Parameters

array $columns

Return Value

array

in Builder at line 4367
protected Builder cloneForPaginationCount()

Clone the existing query instance for usage in a pagination subquery.

Return Value

Builder

in Builder at line 4383
protected array withoutSelectAliases(array $columns)

Remove the column aliases since they will break count queries.

Parameters

array $columns

Return Value

array

in Builder at line 4397
LazyCollection cursor()

Get a lazy collection for the given query.

Return Value

LazyCollection

in Builder at line 4427
protected void enforceOrderBy()

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

Return Value

void

Exceptions

RuntimeException

in Builder at line 4442
Collection pluck(Expression|string $column, string|null $key = null)

Get a collection instance containing the values of a given column.

Parameters

Expression|string $column
string|null $key

Return Value

Collection

in Builder at line 4452
array pluckWithColumn(Expression|string $column, string|null $key = null)

Get column values and the returned field name for Eloquent attribute conversion.

Parameters

Expression|string $column
string|null $key

Return Value

array

in Builder at line 4509
protected string|null stripTableForPluck(Expression|string|null $column)

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

Parameters

Expression|string|null $column

Return Value

string|null

in Builder at line 4527
protected Collection pluckFromObjectColumn(array $queryResult, string $column, string|null $key)

Retrieve column values from rows represented as objects.

Parameters

array $queryResult
string $column
string|null $key

Return Value

Collection

in Builder at line 4547
protected Collection pluckFromArrayColumn(array $queryResult, string $column, string|null $key)

Retrieve column values from rows represented as arrays.

Parameters

array $queryResult
string $column
string|null $key

Return Value

Collection

in Builder at line 4567
string implode(string $column, string $glue = '')

Concatenate values of a given column as a string.

Parameters

string $column
string $glue

Return Value

string

in Builder at line 4575
bool exists()

Determine if any rows exist for the current query.

Return Value

bool

in Builder at line 4601
bool doesntExist()

Determine if no rows exist for the current query.

Return Value

bool

in Builder at line 4609
mixed existsOr(Closure $callback)

Execute the given callback if no rows exist for the current query.

Parameters

Closure $callback

Return Value

mixed

in Builder at line 4617
mixed doesntExistOr(Closure $callback)

Execute the given callback if rows exist for the current query.

Parameters

Closure $callback

Return Value

mixed

in Builder at line 4627
int count(Expression|string $columns = '*')

Retrieve the "count" result of the query.

Parameters

Expression|string $columns

Return Value

int

in Builder at line 4635
mixed min(Expression|string $column)

Retrieve the minimum value of a given column.

Parameters

Expression|string $column

Return Value

mixed

in Builder at line 4643
mixed max(Expression|string $column)

Retrieve the maximum value of a given column.

Parameters

Expression|string $column

Return Value

mixed

in Builder at line 4653
mixed sum(Expression|string $column)

Retrieve the sum of the values of a given column.

Parameters

Expression|string $column

Return Value

mixed

in Builder at line 4665
mixed avg(Expression|string $column)

Retrieve the average of the values of a given column.

Parameters

Expression|string $column

Return Value

mixed

in Builder at line 4675
mixed average(Expression|string $column)

Alias for the "avg" method.

Parameters

Expression|string $column

Return Value

mixed

in Builder at line 4683
mixed aggregate(string $function, array $columns = ['*'])

Execute an aggregate function on the database.

Parameters

string $function
array $columns

Return Value

mixed

in Builder at line 4711
float|int numericAggregate(string $function, array $columns = ['*'])

Execute a numeric aggregate function on the database.

Parameters

string $function
array $columns

Return Value

float|int

in Builder at line 4740
protected Builder setAggregate(string $function, array $columns)

Set the aggregate property without running the query.

Parameters

string $function
array $columns

Return Value

Builder

in Builder at line 4756
protected bool shouldPreserveAggregateOrdering()

Determine whether ordering selects rows retained by the aggregate's inner query.

Return Value

bool

in Builder at line 4773
protected mixed onceWithColumns(array $columns, callable $callback)

Execute the given callback while selecting the given columns.

After running the callback, the columns are reset to the original value.

Parameters

array $columns
callable $callback

Return Value

mixed

in Builder at line 4791
bool insert(array $values)

Insert new records into the database.

Parameters

array $values

Return Value

bool

in Builder at line 4831
int insertOrIgnore(array $values)

Insert new records into the database while ignoring errors.

Parameters

array $values

Return Value

int

in Builder at line 4862
Collection insertOrIgnoreReturning(array $values, array $returning = ['*'], array|string|null $uniqueBy = null)

Insert records while ignoring conflicts and return the inserted rows.

Parameters

array $values
array $returning
array|string|null $uniqueBy

Return Value

Collection

in Builder at line 4910
int|string insertGetId(array $values, string|null $sequence = null)

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

Parameters

array $values
string|null $sequence

Return Value

int|string

in Builder at line 4926
int insertUsing(array $columns, Closure|Builder|Builder|Relation|string $query)

Insert new records into the table using a subquery.

Parameters

array $columns
Closure|Builder|Builder|Relation|string $query

Return Value

int

in Builder at line 4943
int insertOrIgnoreUsing(array $columns, Closure|Builder|Builder|Relation|string $query)

Insert new records into the table using a subquery while ignoring errors.

Parameters

array $columns
Closure|Builder|Builder|Relation|string $query

Return Value

int

in Builder at line 4960
int update(array $values)

Update records in the database.

Parameters

array $values

Return Value

int

in Builder at line 4998
int updateFrom(array $values)

Update records in a PostgreSQL database using the update from syntax.

Parameters

array $values

Return Value

int

Exceptions

LogicException

in Builder at line 5030
bool updateOrInsert(array $attributes, array|callable $values = [])

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

Parameters

array $attributes
array|callable $values

Return Value

bool

in Builder at line 5056
int upsert(array $values, array|string $uniqueBy, array|null $update = null)

Insert new records or update the existing ones.

Parameters

array $values
array|string $uniqueBy
array|null $update

Return Value

int

Exceptions

InvalidArgumentException

in Builder at line 5105
int increment(string $column, mixed $amount = 1, array $extra = [])

Increment a column's value by a given amount.

Parameters

string $column
mixed $amount
array $extra

Return Value

int

Exceptions

InvalidArgumentException

in Builder at line 5123
int incrementEach(array $columns, array $extra = [])

Increment the given column's values by the given amounts.

Parameters

array $columns
array $extra

Return Value

int

Exceptions

InvalidArgumentException

in Builder at line 5146
int decrement(string $column, mixed $amount = 1, array $extra = [])

Decrement a column's value by a given amount.

Parameters

string $column
mixed $amount
array $extra

Return Value

int

Exceptions

InvalidArgumentException

in Builder at line 5164
int decrementEach(array $columns, array $extra = [])

Decrement the given column's values by the given amounts.

Parameters

array $columns
array $extra

Return Value

int

Exceptions

InvalidArgumentException

in Builder at line 5183
int delete(mixed $id = null)

Delete records from the database.

Parameters

mixed $id

Return Value

int

in Builder at line 5205
void truncate()

Run a "truncate" statement on the table.

Return Value

void

at line 109
Builder newQuery()

Get a new instance of the join clause builder.

Return Value

Builder

at line 117
protected Builder forSubQuery()

Create a new query instance for sub-query.

Return Value

Builder

in Builder at line 5238
array getColumns()

Get all of the query builder's columns in a text-only array with all expressions evaluated.

Return Value

array

in Builder at line 5248
Expression raw(mixed $value)

Create a raw database expression.

Parameters

mixed $value

Return Value

Expression

in Builder at line 5256
protected Collection getUnionBuilders()

Get the query builder instances that are used in the union of the query.

Return Value

Collection

in Builder at line 5266
int|null getLimit()

Get the "limit" value for the query or null if it's not set.

Return Value

int|null

in Builder at line 5276
int|null getOffset()

Get the "offset" value for the query or null if it's not set.

Return Value

int|null

in Builder at line 5288
array getBindings()

Get the current query value bindings in a flattened array.

Return Value

array

in Builder at line 5296
protected array getBindingsForSelect()

Get the binding groups in the order used by this select statement.

Return Value

array

in Builder at line 5306
array getRawBindings()

Get the raw array of bindings.

Return Value

array

in Builder at line 5320
Builder setBindings(array $bindings, string $type = 'where')

Set the bindings on the query builder.

Parameters

array $bindings
string $type

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 5339
Builder addBinding(mixed $value, string $type = 'where')

Add a binding to the query.

Parameters

mixed $value
string $type

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 5360
mixed castBinding(mixed $value)

Cast the given binding value.

Parameters

mixed $value

Return Value

mixed

in Builder at line 5374
Builder mergeBindings(Builder $query)

Merge an array of bindings into our bindings.

Parameters

Builder $query

Return Value

Builder

in Builder at line 5388
array cleanBindings(array $bindings)

Remove all of the expressions from a list of bindings.

Parameters

array $bindings

Return Value

array

in Builder at line 5402
protected mixed flattenValue(mixed $value)

Get a scalar type value from an unknown type of input.

Parameters

mixed $value

Return Value

mixed

in Builder at line 5410
protected string defaultKeyName()

Get the default key name of the table.

Return Value

string

in Builder at line 5418
ConnectionInterface getConnection()

Get the database connection instance.

Return Value

ConnectionInterface

in Builder at line 5428
protected void ensureConnectionSupportsVectors()

Ensure the database connection supports vector queries.

Return Value

void

Exceptions

RuntimeException

in Builder at line 5438
Processor getProcessor()

Get the database query processor instance.

Return Value

Processor

in Builder at line 5446
Grammar getGrammar()

Get the query grammar instance.

Return Value

Grammar

in Builder at line 5456
Builder useWritePdo()

Use the write connection when executing the query.

Return Value

Builder

in Builder at line 5472
Builder fetchUsing(mixed ...$fetchUsing)

Set the PDO fetch mode arguments for the query.

The @return $this tag lets @phpstan-this-out reach a chained call.

Parameters

mixed ...$fetchUsing

Return Value

Builder

in Builder at line 5482
protected bool isQueryable(mixed $value)

Determine if the value is a query builder instance or a Closure.

Parameters

mixed $value

Return Value

bool

in Builder at line 5495
protected Builder prepareQueryForEmbedding(Builder $query)

Prepare the query for embedding in another statement.

Parameters

Builder $query

Return Value

Builder

Exceptions

InvalidArgumentException

in Builder at line 5513
Builder clone()

Clone the query.

Return Value

Builder

in Builder at line 5521
Builder cloneWithout(array $properties)

Clone the query without the given properties.

Parameters

array $properties

Return Value

Builder

in Builder at line 5529
protected void resetProperties(array $properties)

Clear query properties while retaining defaults required by non-nullable types.

Parameters

array $properties

Return Value

void

in Builder at line 5544
Builder cloneWithoutBindings(array $except)

Clone the query without the given bindings.

Parameters

array $except

Return Value

Builder

in Builder at line 5558
Builder dump(mixed ...$args)

Dump the current SQL and bindings.

Parameters

mixed ...$args

Return Value

Builder

in Builder at line 5574
Builder dumpRawSql()

Dump the raw current SQL with embedded bindings.

Return Value

Builder

in Builder at line 5584
never dd()

Die and dump the current SQL and bindings.

Return Value

never

in Builder at line 5592
never ddRawSql()

Die and dump the current SQL with embedded bindings.

Return Value

never

in Builder at line 5600
static void flushState()

Flush all static state.

Return Value

void

at line 82
JoinClause on(Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null, string $boolean = 'and')

Add an "on" clause to the join.

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

Closure|Expression|string $first
Expression|string|null $operator
Expression|string|null $second
string $boolean

Return Value

JoinClause

Exceptions

InvalidArgumentException

at line 98
JoinClause orOn(Closure|Expression|string $first, Expression|string|null $operator = null, Expression|string|null $second = null)

Add an "or on" clause to the join.

Parameters

Closure|Expression|string $first
Expression|string|null $operator
Expression|string|null $second

Return Value

JoinClause

at line 125
protected Builder newParentQuery()

Create a new parent query instance.

Return Value

Builder