Builder
class Builder implements Builder
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| ConnectionInterface | $connection | The database connection instance. |
|
| Grammar | $grammar | The database query grammar instance. |
|
| Processor | $processor | The database query post processor instance. |
|
| TBindingType, list<mixed>> | $bindings | The current query value bindings. |
|
| null|Expression|string>} | $aggregate | An aggregate function and column to be run. |
|
| null|Expression|string> | $columns | The columns that should be returned. |
|
| bool|array | $distinct | Indicates if the query returns distinct results. |
|
| Expression|string|null | $from | The table which the query is targeting. |
|
| protected string|null | $fromAlias | The logical alias explicitly supplied for the query source. |
|
| IndexHint|null | $indexHint | The index hint for the query. |
|
| array|null | $joins | The table joins for the query. |
|
| array | $wheres | The where constraints for the query. |
|
| array|null | $groups | The groupings for the query. |
|
| array|null | $havings | The having constraints for the query. |
|
| array|null | $orders | The orderings for the query. |
|
| int|null | $limit | The maximum number of records to return. |
|
| array|null | $groupLimit | The maximum number of records to return per group. |
|
| int|null | $offset | The number of records to skip. |
|
| array|null | $unions | The query union statements. |
|
| int|null | $unionLimit | The maximum number of union records to return. |
|
| int|null | $unionOffset | The number of union records to skip. |
|
| array|null | $unionOrders | The orderings for the union query. |
|
| string|bool|null | $lock | Indicates whether row locking is being used. |
|
| int|null | $timeout | The query execution timeout in seconds. |
|
| array | $beforeQueryCallbacks | The callbacks that should be invoked before the query is executed. |
|
| protected TValue>|void> | $afterQueryCallbacks | The callbacks that should be invoked after retrieving data from the database. |
|
| string[] | $operators | All of the available clause operators. |
|
| string[] | $bitwiseOperators | All of the available bitwise operators. |
|
| bool | $useWritePdo | Whether to use the write connection for the select. |
|
| array | $fetchUsing | The PDO fetch mode arguments for the query. |
|
| protected array|null | $fetchUsingOverride | The scoped PDO fetch mode arguments for the current query, or null when no override is active. |
Methods
Add a where clause to determine if a "date" column is in the past to the query.
Add a where clause to determine if a "date" column is in the past or now to the query.
Add an "or where" clause to determine if a "date" column is in the past to the query.
Add a where clause to determine if a "date" column is in the past or now to the query.
Add a where clause to determine if a "date" column is in the future to the query.
Add a where clause to determine if a "date" column is in the future or now to the query.
Add an "or where" clause to determine if a "date" column is in the future to the query.
Add an "or where" clause to determine if a "date" column is in the future or now to the query.
Add an "where" clause to determine if a "date" column is in the past or future.
Add a "where date" clause to determine if a "date" column is today to the query.
Add a "where date" clause to determine if a "date" column is before today.
Add a "where date" clause to determine if a "date" column is today or before to the query.
Add a "where date" clause to determine if a "date" column is after today.
Add a "where date" clause to determine if a "date" column is today or after to the query.
Add an "or where date" clause to determine if a "date" column is today to the query.
Add an "or where date" clause to determine if a "date" column is before today.
Add an "or where date" clause to determine if a "date" column is today or before to the query.
Add an "or where date" clause to determine if a "date" column is after today.
Add an "or where date" clause to determine if a "date" column is today or after to the query.
Add a "where date" clause to determine if a "date" column is today or after to the query.
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Run a map over each item while chunking.
Execute a callback over each item while chunking.
Chunk the results of a query by comparing IDs.
Chunk the results of a query by comparing IDs in descending order.
Chunk the results of a query by comparing IDs in a given order.
Execute a callback over each item while chunking by ID.
Query lazily, by chunks of the given size.
Query lazily, by chunking the results of a query by comparing IDs.
Query lazily, by chunking the results of a query by comparing IDs in descending order.
Query lazily, by chunking the results of a query by comparing IDs in a given order.
Execute the query and get the first result.
Execute the query and get the first result or throw an exception.
Execute the query and get the first result if it's the sole matching record.
Paginate the given query using a cursor paginator.
Get the original column name of the given column, without any aliasing.
Create a new length-aware paginator instance.
Create a new simple paginator instance.
Create a new cursor paginator instance.
Pass the query to a given callback and then return it.
Pass the query to a given callback and return the result.
Forward a method call to the given object.
Forward a method call to the given object, returning $this if the forwarded call returned itself.
Throw a bad method call exception for the given method.
Mix another object into the class.
Dynamically handle calls to the class.
Handle dynamic method calls into the method.
Create a new query builder instance.
Add a new "raw" select expression to the query.
Parse the subquery into SQL and bindings.
Prepend the database name if the given query is on another database.
Get the wildcard selection for the query's primary source.
Add a vector-similarity selection to the query.
Get the alias or table name that qualifies the query's source columns.
Add an index hint to force a query index.
Add an index hint to ignore a query index.
Add a "join" clause to the query.
Add a "join where" clause to the query.
Add a "subquery join" clause to the query.
Add a "lateral join" clause to the query.
Add a lateral left join to the query.
Add a left join to the query.
Add a "join where" clause to the query.
Add a subquery left join to the query.
Add a right join to the query.
Add a "right join where" clause to the query.
Add a subquery right join to the query.
Add a "cross join" clause to the query.
Add a subquery cross join to the query.
Add a straight join to the query.
Add a straight join where clause to the query.
Add a subquery straight join to the query.
Get a new "join" clause.
Get a new "join lateral" clause.
Merge an array of "where" clauses and bindings.
Add an array of "where" clauses to the query.
Prepare the value and operator for a where clause.
Determine if the given operator and value combination is legal.
Determine if the given operator is supported.
Determine if the operator is a bitwise operator.
Add an "or where not" clause to the query.
Add a "where" clause comparing two columns to the query.
Add an "or where" clause comparing two columns to the query.
Add a vector similarity clause to the query, filtering by minimum similarity and ordering by similarity.
Add a vector distance "where" clause to the query.
Add a vector distance "or where" clause to the query.
Add a raw "where" clause to the query.
Add a raw "or where" clause to the query.
Add a "where binary" clause to the query.
Add an "or where binary" clause to the query.
Add a "where not binary" clause to the query.
Add an "or where not binary" clause to the query.
Add a "where like" clause to the query.
Add an "or where like" clause to the query.
Add a "where not like" clause to the query.
Add an "or where not like" clause to the query.
Add a null-safe equality clause to the query.
Add an "or" null-safe equality clause to the query.
Add a "where in" clause to the query.
Add a "where not in" clause to the query.
Add an "or where not in" clause to the query.
Add a "where in raw" clause for integer values to the query.
Add an "or where in raw" clause for integer values to the query.
Add a "where not in raw" clause for integer values to the query.
Add an "or where not in raw" clause for integer values to the query.
Add a "where null" clause to the query.
Add a "where not null" clause to the query.
Add a "where between" statement to the query.
Add a "where between" statement using columns to the query.
Add an "or where between" statement to the query.
Add an "or where between" statement using columns to the query.
Add a "where not between" statement to the query.
Add a "where not between" statement using columns to the query.
Add an "or where not between" statement to the query.
Add an "or where not between" statement using columns to the query.
Add a "where between columns" statement using a value to the query.
Add an "or where between columns" statement using a value to the query.
Add a "where not between columns" statement using a value to the query.
Add an "or where not between columns" statement using a value to the query.
Add a "where date" statement to the query.
Add an "or where date" statement to the query.
Add a "where time" statement to the query.
Add an "or where time" statement to the query.
Add a "where day" statement to the query.
Add an "or where day" statement to the query.
Add a "where month" statement to the query.
Add an "or where month" statement to the query.
Add a "where year" statement to the query.
Add an "or where year" statement to the query.
Add a date based (year, month, day, time) statement to the query.
Add a nested "where" statement to the query.
Create a new query instance for nested where condition.
Add another query builder as a nested where to the query builder.
Add an "exists" clause to the query.
Add an "or where exists" clause to the query.
Add a "where not exists" clause to the query.
Add an "or where not exists" clause to the query.
Add an "exists" clause to the query.
Adds a where condition using row values.
Adds an or where condition using row values.
Add a "where JSON contains" clause to the query.
Add an "or where JSON contains" clause to the query.
Add a "where JSON not contains" clause to the query.
Add an "or where JSON not contains" clause to the query.
Add a "where JSON overlaps" clause to the query.
Add an "or where JSON overlaps" clause to the query.
Add a "where JSON not overlap" clause to the query.
Add an "or where JSON not overlap" clause to the query.
Add a clause that determines if a JSON path exists to the query.
Add an "or" clause that determines if a JSON path exists to the query.
Add a clause that determines if a JSON path does not exist to the query.
Add an "or" clause that determines if a JSON path does not exist to the query.
Add a "where JSON length" clause to the query.
Add an "or where JSON length" clause to the query.
Handles dynamic "where" clauses to the query.
Add a single dynamic "where" clause statement to the query.
Add a "where fulltext" clause to the query.
Add an "or where fulltext" clause to the query.
Add a "where" clause to the query for multiple columns with "and" conditions between them.
Add an "or where" clause to the query for multiple columns with "and" conditions between them.
Add a "where" clause to the query for multiple columns with "or" conditions between them.
Add an "or where" clause to the query for multiple columns with "or" conditions between them.
Add a "where not" clause to the query for multiple columns where none of the conditions should be true.
Add an "or where not" clause to the query for multiple columns where none of the conditions should be true.
Add a raw "groupBy" clause to the query.
Add a "having" clause to the query.
Add an "or having" clause to the query.
Add a nested "having" statement to the query.
Add another query builder as a nested having to the query builder.
Add a "having null" clause to the query.
Add an "or having null" clause to the query.
Add a "having not null" clause to the query.
Add an "or having not null" clause to the query.
Add a "having between" clause to the query.
Add a "having not between" clause to the query.
Add an "or having between" clause to the query.
Add an "or having not between" clause to the query.
Add a raw "having" clause to the query.
Add a raw "or having" clause to the query.
Add a descending "order by" clause to the query.
Add a vector-distance "order by" clause to the query.
Put the query's results in random order.
Add an "order by" clause to order results by a given sequence of values.
Add a raw "order by" clause to the query.
Add a "group limit" clause to the query.
Constrain the query to the previous "page" of results before a given ID.
Constrain the query to the next "page" of results after a given ID.
Add descending "reorder" clause to the query.
Get an array with all orders with a given column removed.
Lock the selected rows in the table for updating.
Share lock the selected rows in the table.
Register a closure to be invoked before the query is executed.
Invoke the "before query" modification callbacks.
Get the SQL representation of the query.
Get the raw SQL representation of the query with embedded bindings.
Execute a query for a single record by ID.
Execute a query for a single record by ID or call a callback.
Get a single expression value from the first result of a query.
Get a single column's value from the first result of a query if it's the sole matching record.
Run the query as a "select" statement against the connection.
Execute the given callback without custom fetch mode arguments.
Remove the group limit keys from the results in the collection.
Paginate the given query into a simple paginator.
Get a paginator only supporting simple next and previous links.
Get a paginator only supporting simple next and previous links.
Ensure the proper order by required for cursor pagination.
Get the count of the total records for the paginator.
Run a pagination count query.
Clone the existing query instance for usage in a pagination subquery.
Remove the column aliases since they will break count queries.
Get a lazy collection for the given query.
Throw an exception if the query doesn't have an orderBy clause.
Get a collection instance containing the values of a given column.
Get column values and the returned field name for Eloquent attribute conversion.
Strip off the table name or alias from a column identifier.
Retrieve column values from rows represented as objects.
Retrieve column values from rows represented as arrays.
Concatenate values of a given column as a string.
Determine if any rows exist for the current query.
Determine if no rows exist for the current query.
Execute an aggregate function on the database.
Execute a numeric aggregate function on the database.
Set the aggregate property without running the query.
Execute the given callback while selecting the given columns.
Insert new records into the database.
Insert new records into the database while ignoring errors.
Insert records while ignoring conflicts and return the inserted rows.
Insert a new record and get the value of the primary key.
Insert new records into the table using a subquery.
Insert new records into the table using a subquery while ignoring errors.
Update records in the database.
Update records in a PostgreSQL database using the update from syntax.
Insert or update a record matching the attributes, and fill it with values.
Insert new records or update the existing ones.
Increment a column's value by a given amount.
Increment the given column's values by the given amounts.
Decrement a column's value by a given amount.
Decrement the given column's values by the given amounts.
Delete records from the database.
Run a "truncate" statement on the table.
Create a new query instance for a sub-query.
Get all of the query builder's columns in a text-only array with all expressions evaluated.
Create a raw database expression.
Get the query builder instances that are used in the union of the query.
Get the "limit" value for the query or null if it's not set.
Get the "offset" value for the query or null if it's not set.
Get the current query value bindings in a flattened array.
Get the raw array of bindings.
Set the bindings on the query builder.
Add a binding to the query.
Cast the given binding value.
Remove all of the expressions from a list of bindings.
Get a scalar type value from an unknown type of input.
Get the default key name of the table.
Get the database connection instance.
Ensure the database connection supports vector queries.
Get the database query processor instance.
Get the query grammar instance.
Use the write connection when executing the query.
Set the PDO fetch mode arguments for the query.
Determine if the value is a query builder instance or a Closure.
Clone the query without the given properties.
Clone the query without the given bindings.
Dump the raw current SQL with embedded bindings.
Die and dump the current SQL and bindings.
Die and dump the current SQL with embedded bindings.
Flush all static state.
Details
in
BuildsWhereDateClauses at line 17
BuildsWhereDateClauses
wherePast(array|string $columns)
Add a where clause to determine if a "date" column is in the past to the query.
in
BuildsWhereDateClauses at line 27
BuildsWhereDateClauses
whereNowOrPast(array|string $columns)
Add a where clause to determine if a "date" column is in the past or now to the query.
in
BuildsWhereDateClauses at line 37
BuildsWhereDateClauses
orWherePast(array|string $columns)
Add an "or where" clause to determine if a "date" column is in the past to the query.
in
BuildsWhereDateClauses at line 47
BuildsWhereDateClauses
orWhereNowOrPast(array|string $columns)
Add a where clause to determine if a "date" column is in the past or now to the query.
in
BuildsWhereDateClauses at line 57
BuildsWhereDateClauses
whereFuture(array|string $columns)
Add a where clause to determine if a "date" column is in the future to the query.
in
BuildsWhereDateClauses at line 67
BuildsWhereDateClauses
whereNowOrFuture(array|string $columns)
Add a where clause to determine if a "date" column is in the future or now to the query.
in
BuildsWhereDateClauses at line 77
BuildsWhereDateClauses
orWhereFuture(array|string $columns)
Add an "or where" clause to determine if a "date" column is in the future to the query.
in
BuildsWhereDateClauses at line 87
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.
in
BuildsWhereDateClauses at line 97
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.
in
BuildsWhereDateClauses at line 116
BuildsWhereDateClauses
whereToday(array|string $columns, string $boolean = 'and')
Add a "where date" clause to determine if a "date" column is today to the query.
in
BuildsWhereDateClauses at line 126
BuildsWhereDateClauses
whereBeforeToday(array|string $columns)
Add a "where date" clause to determine if a "date" column is before today.
in
BuildsWhereDateClauses at line 136
BuildsWhereDateClauses
whereTodayOrBefore(array|string $columns)
Add a "where date" clause to determine if a "date" column is today or before to the query.
in
BuildsWhereDateClauses at line 146
BuildsWhereDateClauses
whereAfterToday(array|string $columns)
Add a "where date" clause to determine if a "date" column is after today.
in
BuildsWhereDateClauses at line 156
BuildsWhereDateClauses
whereTodayOrAfter(array|string $columns)
Add a "where date" clause to determine if a "date" column is today or after to the query.
in
BuildsWhereDateClauses at line 166
BuildsWhereDateClauses
orWhereToday(array|string $columns)
Add an "or where date" clause to determine if a "date" column is today to the query.
in
BuildsWhereDateClauses at line 176
BuildsWhereDateClauses
orWhereBeforeToday(array|string $columns)
Add an "or where date" clause to determine if a "date" column is before today.
in
BuildsWhereDateClauses at line 186
BuildsWhereDateClauses
orWhereTodayOrBefore(array|string $columns)
Add an "or where date" clause to determine if a "date" column is today or before to the query.
in
BuildsWhereDateClauses at line 196
BuildsWhereDateClauses
orWhereAfterToday(array|string $columns)
Add an "or where date" clause to determine if a "date" column is after today.
in
BuildsWhereDateClauses at line 206
BuildsWhereDateClauses
orWhereTodayOrAfter(array|string $columns)
Add an "or where date" clause to determine if a "date" column is today or after to the query.
in
BuildsWhereDateClauses at line 216
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.
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.
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.
in
BuildsQueries at line 42
bool
chunk(int $count, callable $callback)
Chunk the results of the query.
in
BuildsQueries at line 99
Collection
chunkMap(callable $callback, int $count = 1000)
Run a map over each item while chunking.
in
BuildsQueries at line 117
bool
each(callable $callback, int $count = 1000)
Execute a callback over each item while chunking.
in
BuildsQueries at line 135
bool
chunkById(int $count, callable $callback, string|null $column = null, string|null $alias = null)
Chunk the results of a query by comparing IDs.
in
BuildsQueries at line 145
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.
in
BuildsQueries at line 155
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.
in
BuildsQueries at line 227
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.
in
BuildsQueries at line 245
LazyCollection
lazy(int $chunkSize = 1000)
Query lazily, by chunks of the given size.
in
BuildsQueries at line 296
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.
in
BuildsQueries at line 306
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.
in
BuildsQueries at line 319
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.
in
BuildsQueries at line 385
null|TValue
first(array|string $columns = ['*'])
Execute the query and get the first result.
in
BuildsQueries at line 398
TValue
firstOrFail(array|string $columns = ['*'], string|null $message = null)
Execute the query and get the first result or throw an exception.
in
BuildsQueries at line 418
TValue
sole(array|string $columns = ['*'])
Execute the query and get the first result if it's the sole matching record.
in
BuildsQueries at line 439
protected CursorPaginator
paginateUsingCursor(int $perPage, array|string $columns = ['*'], string $cursorName = 'cursor', Cursor|string|null $cursor = null)
Paginate the given query using a cursor paginator.
in
BuildsQueries at line 538
protected string
getOriginalColumnNameForCursorPagination(Builder|Builder $builder, string $parameter)
Get the original column name of the given column, without any aliasing.
in
BuildsQueries at line 560
protected LengthAwarePaginator
paginator(Collection $items, int $total, int $perPage, int $currentPage, array $options)
Create a new length-aware paginator instance.
in
BuildsQueries at line 570
protected Paginator
simplePaginator(Collection $items, int $perPage, int $currentPage, array $options)
Create a new simple paginator instance.
in
BuildsQueries at line 580
protected CursorPaginator
cursorPaginator(Collection $items, int $perPage, Cursor|null $cursor, array $options)
Create a new cursor paginator instance.
in
BuildsQueries at line 593
BuildsQueries
tap(callable $callback)
Pass the query to a given callback and then return it.
in
BuildsQueries at line 608
TReturn is null|TReturn)
pipe(callable $callback)
Pass the query to a given callback and return the result.
in
ExplainsQueries at line 17
Collection
explain()
Explain the query.
in
ForwardsCalls at line 22
protected mixed
forwardCallTo(mixed $object, string $method, array $parameters)
Forward a method call to the given object.
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.
in
ForwardsCalls at line 66
static protected never
throwBadMethodCallException(string $method)
Throw a bad method call exception for the given method.
in
Macroable at line 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
at line 4454
mixed
__call(string $method, array $parameters)
Handle dynamic method calls into the method.
at line 254
__construct(ConnectionInterface $connection, Grammar|null $grammar = null, Processor|null $processor = null)
Create a new query builder instance.
at line 267
Builder
select(mixed $columns = ['*'])
Set the columns to be selected.
at line 292
Builder
selectSub(Closure|Builder|Builder|Relation|string $query, string $as)
Add a subselect expression to the query.
at line 305
Builder
selectExpression(Expression|string $expression, string $as)
Add a select expression to the query.
at line 315
Builder
selectRaw(string $expression, array $bindings = [])
Add a new "raw" select expression to the query.
at line 333
Builder
fromSub(Closure|Builder|Builder|Relation|string $query, string $as)
Makes "from" fetch from a subquery.
at line 347
Builder
fromRaw(Expression|string $expression, mixed $bindings = [])
Add a raw "from" clause to the query.
at line 365
protected array
createSub(Closure|Builder|Builder|Relation|string $query)
Creates a subquery and parse it.
at line 384
protected array
parseSub(mixed $query)
Parse the subquery into SQL and bindings.
at line 412
protected Builder
prependDatabaseNameIfCrossDatabaseQuery(Builder $query)
Prepend the database name if the given query is on another database.
at line 431
Builder
addSelect(mixed $column)
Add a new select column to the query.
at line 459
string
getDefaultSelectColumn()
Get the wildcard selection for the query's primary source.
at line 479
Builder
selectVectorDistance(Expression|string $column, Collection|Arrayable|array|string $vector, string|null $as = null)
Add a vector-similarity selection to the query.
at line 510
Builder
distinct()
Force the query to only return distinct results.
at line 528
Builder
from(Closure|Builder|Builder|Relation|Expression|string $table, string|null $as = null)
Set the table which the query is targeting.
at line 550
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.
at line 558
Builder
useIndex(string $index)
Add an index hint to suggest a query index.
at line 568
Builder
forceIndex(string $index)
Add an index hint to force a query index.
at line 578
Builder
ignoreIndex(string $index)
Add an index hint to ignore a query index.
at line 588
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.
at line 620
Builder
joinWhere(Expression|string $table, Closure|Expression|string $first, string $operator, mixed $second, string $type = 'inner')
Add a "join where" clause to the query.
at line 632
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.
at line 653
Builder
joinLateral(Closure|Builder|Builder|Relation|string $query, string $as, string $type = 'inner')
Add a "lateral join" clause to the query.
at line 671
Builder
leftJoinLateral(Closure|Builder|Builder|Relation|string $query, string $as)
Add a lateral left join to the query.
at line 679
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.
at line 687
Builder
leftJoinWhere(Expression|string $table, Closure|Expression|string $first, string $operator, mixed $second)
Add a "join where" clause to the query.
at line 697
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.
at line 705
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.
at line 713
Builder
rightJoinWhere(Expression|string $table, Closure|Expression|string $first, string $operator, mixed $second)
Add a "right join where" clause to the query.
at line 723
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.
at line 731
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.
at line 747
Builder
crossJoinSub(Closure|Builder|Builder|Relation|string $query, string $as)
Add a subquery cross join to the query.
at line 763
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.
at line 771
Builder
straightJoinWhere(Expression|string $table, Closure|Expression|string $first, string $operator, mixed $second)
Add a straight join where clause to the query.
at line 781
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.
at line 789
protected JoinClause
newJoinClause(Builder $parentQuery, string $type, Expression|string $table)
Get a new "join" clause.
at line 797
protected JoinLateralClause
newJoinLateralClause(Builder $parentQuery, string $type, Expression|string $table)
Get a new "join lateral" clause.
at line 805
Builder
mergeWheres(array $wheres, array $bindings)
Merge an array of "where" clauses and bindings.
at line 819
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.
at line 926
protected Builder
addArrayOfWheres(array $column, string $boolean, string $method = 'where')
Add an array of "where" clauses to the query.
at line 944
array
prepareValueAndOperator(mixed $value, mixed $operator, bool $useDefault = false)
Prepare the value and operator for a where clause.
at line 961
protected bool
invalidOperatorAndValue(mixed $operator, mixed $value)
Determine if the given operator and value combination is legal.
Prevents using Null values with invalid operators.
at line 970
protected bool
invalidOperator(mixed $operator)
Determine if the given operator is supported.
at line 979
protected bool
isBitwiseOperator(string $operator)
Determine if the operator is a bitwise operator.
at line 988
Builder
orWhere(Closure|Builder|Builder|Relation|Expression|array|string $column, mixed $operator = null, mixed $value = null)
Add an "or where" clause to the query.
at line 1002
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.
at line 1016
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.
at line 1024
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.
at line 1055
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.
at line 1068
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.
at line 1092
Builder
whereVectorDistanceLessThan(Expression|string $column, Collection|Arrayable|array|string $vector, float $maxDistance, string $boolean = 'and')
Add a vector distance "where" clause to the query.
at line 1122
Builder
orWhereVectorDistanceLessThan(Expression|string $column, Collection|Arrayable|array|string $vector, float $maxDistance)
Add a vector distance "or where" clause to the query.
at line 1130
Builder
whereRaw(Expression|string $sql, mixed $bindings = [], string $boolean = 'and')
Add a raw "where" clause to the query.
at line 1142
Builder
orWhereRaw(string $sql, mixed $bindings = [])
Add a raw "or where" clause to the query.
at line 1150
Builder
whereBinary(Expression|string $column, string $value, string $boolean = 'and', bool $not = false)
Add a "where binary" clause to the query.
at line 1164
Builder
orWhereBinary(Expression|string $column, string $value)
Add an "or where binary" clause to the query.
at line 1172
Builder
whereNotBinary(Expression|string $column, string $value, string $boolean = 'and')
Add a "where not binary" clause to the query.
at line 1180
Builder
orWhereNotBinary(Expression|string $column, string $value)
Add an "or where not binary" clause to the query.
at line 1188
Builder
whereLike(Expression|string $column, string $value, bool $caseSensitive = false, string $boolean = 'and', bool $not = false)
Add a "where like" clause to the query.
at line 1206
Builder
orWhereLike(Expression|string $column, string $value, bool $caseSensitive = false)
Add an "or where like" clause to the query.
at line 1214
Builder
whereNotLike(Expression|string $column, string $value, bool $caseSensitive = false, string $boolean = 'and')
Add a "where not like" clause to the query.
at line 1222
Builder
orWhereNotLike(Expression|string $column, string $value, bool $caseSensitive = false)
Add an "or where not like" clause to the query.
at line 1230
Builder
whereNullSafeEquals(Expression|string $column, mixed $value, string $boolean = 'and')
Add a null-safe equality clause to the query.
at line 1250
Builder
orWhereNullSafeEquals(Expression|string $column, mixed $value)
Add an "or" null-safe equality clause to the query.
at line 1260
Builder
whereIn(Expression|string $column, mixed $values, string $boolean = 'and', bool $not = false)
Add a "where in" clause to the query.
at line 1299
Builder
orWhereIn(Expression|string $column, mixed $values)
Add an "or where in" clause to the query.
at line 1307
Builder
whereNotIn(Expression|string $column, mixed $values, string $boolean = 'and')
Add a "where not in" clause to the query.
at line 1315
Builder
orWhereNotIn(Expression|string $column, mixed $values)
Add an "or where not in" clause to the query.
at line 1323
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.
at line 1345
Builder
orWhereIntegerInRaw(string $column, Arrayable|array $values)
Add an "or where in raw" clause for integer values to the query.
at line 1353
Builder
whereIntegerNotInRaw(string $column, Arrayable|array $values, string $boolean = 'and')
Add a "where not in raw" clause for integer values to the query.
at line 1361
Builder
orWhereIntegerNotInRaw(string $column, Arrayable|array $values)
Add an "or where not in raw" clause for integer values to the query.
at line 1369
Builder
whereNull(string|array|Expression $columns, string $boolean = 'and', bool $not = false)
Add a "where null" clause to the query.
at line 1383
Builder
orWhereNull(string|array|Expression $column)
Add an "or where null" clause to the query.
at line 1391
Builder
whereNotNull(string|array|Expression $columns, string $boolean = 'and')
Add a "where not null" clause to the query.
at line 1401
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.
at line 1430
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.
at line 1451
Builder
orWhereBetween(Closure|Builder|Builder|Relation|Expression|string $column, iterable $values)
Add an "or where between" statement to the query.
at line 1459
Builder
orWhereBetweenColumns(Closure|Builder|Builder|Relation|Expression|string $column, array $values)
Add an "or where between" statement using columns to the query.
at line 1469
Builder
whereNotBetween(Closure|Builder|Builder|Relation|Expression|string $column, iterable $values, string $boolean = 'and')
Add a "where not between" statement to the query.
at line 1477
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.
at line 1487
Builder
orWhereNotBetween(Closure|Builder|Builder|Relation|Expression|string $column, iterable $values)
Add an "or where not between" statement to the query.
at line 1495
Builder
orWhereNotBetweenColumns(Closure|Builder|Builder|Relation|Expression|string $column, array $values)
Add an "or where not between" statement using columns to the query.
at line 1505
Builder
whereValueBetween(mixed $value, array $columns, string $boolean = 'and', bool $not = false)
Add a "where between columns" statement using a value to the query.
at line 1524
Builder
orWhereValueBetween(mixed $value, array $columns)
Add an "or where between columns" statement using a value to the query.
at line 1534
Builder
whereValueNotBetween(mixed $value, array $columns, string $boolean = 'and')
Add a "where not between columns" statement using a value to the query.
at line 1544
Builder
orWhereValueNotBetween(mixed $value, array $columns)
Add an "or where not between columns" statement using a value to the query.
at line 1552
Builder
orWhereNotNull(array|Expression|string $column)
Add an "or where not null" clause to the query.
at line 1560
Builder
whereDate(Expression|Stringable|string $column, mixed $operator, mixed $value = null, string $boolean = 'and')
Add a "where date" statement to the query.
at line 1587
Builder
orWhereDate(Expression|Stringable|string $column, mixed $operator, mixed $value = null)
Add an "or where date" statement to the query.
at line 1601
Builder
whereTime(Expression|Stringable|string $column, mixed $operator, mixed $value = null, string $boolean = 'and')
Add a "where time" statement to the query.
at line 1628
Builder
orWhereTime(Expression|Stringable|string $column, mixed $operator, mixed $value = null)
Add an "or where time" statement to the query.
at line 1642
Builder
whereDay(Expression|Stringable|string $column, mixed $operator, mixed $value = null, string $boolean = 'and')
Add a "where day" statement to the query.
at line 1674
Builder
orWhereDay(Expression|Stringable|string $column, mixed $operator, mixed $value = null)
Add an "or where day" statement to the query.
at line 1688
Builder
whereMonth(Expression|Stringable|string $column, mixed $operator, mixed $value = null, string $boolean = 'and')
Add a "where month" statement to the query.
at line 1720
Builder
orWhereMonth(Expression|Stringable|string $column, mixed $operator, mixed $value = null)
Add an "or where month" statement to the query.
at line 1734
Builder
whereYear(Expression|Stringable|string $column, mixed $operator, mixed $value = null, string $boolean = 'and')
Add a "where year" statement to the query.
at line 1761
Builder
orWhereYear(Expression|Stringable|string $column, mixed $operator, mixed $value = null)
Add an "or where year" statement to the query.
at line 1775
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.
at line 1792
Builder
whereNested(Closure $callback, string $boolean = 'and')
Add a nested "where" statement to the query.
at line 1802
Builder
forNestedWhere()
Create a new query instance for nested where condition.
at line 1816
Builder
addNestedWhereQuery(Builder $query, string $boolean = 'and')
Add another query builder as a nested where to the query builder.
at line 1836
protected Builder
whereSub(Expression|string $column, string $operator, Closure|Builder|Builder|Relation $callback, string $boolean)
Add a full sub-select to the query.
at line 1867
Builder
whereExists(Closure|Builder|Builder $callback, string $boolean = 'and', bool $not = false)
Add an "exists" clause to the query.
at line 1890
Builder
orWhereExists(Closure|Builder|Builder $callback, bool $not = false)
Add an "or where exists" clause to the query.
at line 1902
Builder
whereNotExists(Closure|Builder|Builder $callback, string $boolean = 'and')
Add a "where not exists" clause to the query.
at line 1914
Builder
orWhereNotExists(Closure|Builder|Builder $callback)
Add an "or where not exists" clause to the query.
at line 1924
Builder
addWhereExistsQuery(Builder $query, string $boolean = 'and', bool $not = false)
Add an "exists" clause to the query.
at line 1942
Builder
whereRowValues(array $columns, string $operator, array $values, string $boolean = 'and')
Adds a where condition using row values.
at line 1960
Builder
orWhereRowValues(array $columns, string $operator, array $values)
Adds an or where condition using row values.
at line 1968
Builder
whereJsonContains(string $column, mixed $value, string $boolean = 'and', bool $not = false)
Add a "where JSON contains" clause to the query.
at line 1984
Builder
orWhereJsonContains(string $column, mixed $value)
Add an "or where JSON contains" clause to the query.
at line 1992
Builder
whereJsonDoesntContain(string $column, mixed $value, string $boolean = 'and')
Add a "where JSON not contains" clause to the query.
at line 2000
Builder
orWhereJsonDoesntContain(string $column, mixed $value)
Add an "or where JSON not contains" clause to the query.
at line 2008
Builder
whereJsonOverlaps(string $column, mixed $value, string $boolean = 'and', bool $not = false)
Add a "where JSON overlaps" clause to the query.
at line 2024
Builder
orWhereJsonOverlaps(string $column, mixed $value)
Add an "or where JSON overlaps" clause to the query.
at line 2032
Builder
whereJsonDoesntOverlap(string $column, mixed $value, string $boolean = 'and')
Add a "where JSON not overlap" clause to the query.
at line 2040
Builder
orWhereJsonDoesntOverlap(string $column, mixed $value)
Add an "or where JSON not overlap" clause to the query.
at line 2048
Builder
whereJsonContainsKey(string $column, string $boolean = 'and', bool $not = false)
Add a clause that determines if a JSON path exists to the query.
at line 2060
Builder
orWhereJsonContainsKey(string $column)
Add an "or" clause that determines if a JSON path exists to the query.
at line 2068
Builder
whereJsonDoesntContainKey(string $column, string $boolean = 'and')
Add a clause that determines if a JSON path does not exist to the query.
at line 2076
Builder
orWhereJsonDoesntContainKey(string $column)
Add an "or" clause that determines if a JSON path does not exist to the query.
at line 2084
Builder
whereJsonLength(string $column, mixed $operator, mixed $value = null, string $boolean = 'and')
Add a "where JSON length" clause to the query.
at line 2113
Builder
orWhereJsonLength(string $column, mixed $operator, mixed $value = null)
Add an "or where JSON length" clause to the query.
at line 2127
Builder
dynamicWhere(string $method, array $parameters)
Handles dynamic "where" clauses to the query.
at line 2169
protected void
addDynamic(string $segment, string $connector, array $parameters, int $index)
Add a single dynamic "where" clause statement to the query.
at line 2182
Builder
whereFullText(string|array $columns, string $value, array $options = [], string $boolean = 'and')
Add a "where fulltext" clause to the query.
at line 2198
Builder
orWhereFullText(string|array $columns, string $value, array $options = [])
Add an "or where fulltext" clause to the query.
at line 2208
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.
at line 2230
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.
at line 2240
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.
at line 2262
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.
at line 2272
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.
at line 2282
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.
at line 2290
Builder
groupBy(array|Expression|string ...$groups)
Add a "group by" clause to the query.
at line 2305
Builder
groupByRaw(string $sql, array $bindings = [])
Add a raw "groupBy" clause to the query.
at line 2317
Builder
having(Expression|Closure|string $column, mixed $operator = null, mixed $value = null, string $boolean = 'and')
Add a "having" clause to the query.
at line 2369
Builder
orHaving(Expression|Closure|string $column, mixed $operator = null, mixed $value = null)
Add an "or having" clause to the query.
at line 2386
Builder
havingNested(Closure $callback, string $boolean = 'and')
Add a nested "having" statement to the query.
at line 2396
Builder
addNestedHavingQuery(Builder $query, string $boolean = 'and')
Add another query builder as a nested having to the query builder.
at line 2412
Builder
havingNull(array|string $columns, string $boolean = 'and', bool $not = false)
Add a "having null" clause to the query.
at line 2426
Builder
orHavingNull(string $column)
Add an "or having null" clause to the query.
at line 2434
Builder
havingNotNull(array|string $columns, string $boolean = 'and')
Add a "having not null" clause to the query.
at line 2442
Builder
orHavingNotNull(string $column)
Add an "or having not null" clause to the query.
at line 2450
Builder
havingBetween(string $column, iterable $values, string $boolean = 'and', bool $not = false)
Add a "having between" clause to the query.
at line 2470
Builder
havingNotBetween(string $column, iterable $values, string $boolean = 'and')
Add a "having not between" clause to the query.
at line 2478
Builder
orHavingBetween(string $column, iterable $values)
Add an "or having between" clause to the query.
at line 2486
Builder
orHavingNotBetween(string $column, iterable $values)
Add an "or having not between" clause to the query.
at line 2496
protected array
resolveDatePeriodBounds(DatePeriod $period)
Resolve the start and end dates from a DatePeriod.
at line 2515
Builder
havingRaw(string $sql, array $bindings = [], string $boolean = 'and')
Add a raw "having" clause to the query.
at line 2529
Builder
orHavingRaw(string $sql, array $bindings = [])
Add a raw "or having" clause to the query.
at line 2542
Builder
orderBy(Closure|Builder|Builder|Relation|Expression|string $column, SortDirection|string $direction = SortDirection::Ascending)
Add an "order by" clause to the query.
at line 2575
Builder
orderByDesc(Closure|Builder|Builder|Relation|Expression|string $column)
Add a descending "order by" clause to the query.
at line 2583
Builder
latest(Closure|Builder|Builder|Relation|Expression|string $column = 'created_at')
Add an "order by" clause for a timestamp to the query.
at line 2591
Builder
oldest(Closure|Builder|Builder|Relation|Expression|string $column = 'created_at')
Add an "order by" clause for a timestamp to the query.
at line 2603
Builder
orderByVectorDistance(Expression|string $column, Collection|Arrayable|array|string $vector)
Add a vector-distance "order by" clause to the query.
at line 2632
Builder
inRandomOrder(string|int $seed = '')
Put the query's results in random order.
at line 2642
Builder
inOrderOf(Expression|string $column, Arrayable|array $values)
Add an "order by" clause to order results by a given sequence of values.
at line 2673
Builder
orderByRaw(string $sql, mixed $bindings = [])
Add a raw "order by" clause to the query.
at line 2687
Builder
skip(int $value)
Alias to set the "offset" value of the query.
at line 2695
Builder
offset(int|null $value)
Set the "offset" value of the query.
at line 2707
Builder
take(int $value)
Alias to set the "limit" value of the query.
at line 2715
Builder
limit(int|null $value)
Set the "limit" value of the query.
at line 2729
Builder
groupLimit(int $value, string $column)
Add a "group limit" clause to the query.
at line 2741
Builder
forPage(int $page, int $perPage = 15)
Set the limit and offset for a given page.
at line 2749
Builder
forPageBeforeId(int $perPage = 15, string|int|null $lastId = 0, string $column = 'id')
Constrain the query to the previous "page" of results before a given ID.
at line 2766
Builder
forPageAfterId(int $perPage = 15, string|int|null $lastId = 0, string $column = 'id')
Constrain the query to the next "page" of results after a given ID.
at line 2785
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.
at line 2802
Builder
reorderDesc(Closure|Builder|Builder|Relation|Expression|string|null $column)
Add descending "reorder" clause to the query.
at line 2810
protected array
removeExistingOrdersFor(string $column)
Get an array with all orders with a given column removed.
at line 2825
Builder
union(Closure|Builder|Builder $query, bool $all = false)
Add a "union" statement to the query.
at line 2851
Builder
unionAll(Closure|Builder|Builder $query)
Add a "union all" statement to the query.
at line 2859
Builder
lock(string|bool $value = true)
Lock the selected rows in the table.
at line 2870
Builder
lockForUpdate()
Lock the selected rows in the table for updating.
at line 2878
Builder
sharedLock()
Share lock the selected rows in the table.
at line 2888
Builder
timeout(int|null $seconds)
Set a query execution timeout in seconds.
at line 2902
Builder
beforeQuery(callable $callback)
Register a closure to be invoked before the query is executed.
at line 2912
void
applyBeforeQueryCallbacks()
Invoke the "before query" modification callbacks.
at line 2926
Builder
afterQuery(Closure $callback)
Register a closure to be invoked after the query is executed.
at line 2939
Collection
applyAfterQueryCallbacks(Collection $result)
Invoke the "after query" modification callbacks.
at line 2951
string
toSql()
Get the SQL representation of the query.
at line 2961
string
toRawSql()
Get the raw SQL representation of the query with embedded bindings.
at line 2975
mixed
find(int|string $id, Expression|array|string $columns = ['*'])
Execute a query for a single record by ID.
at line 2989
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.
at line 3010
mixed
value(Expression|string $column)
Get a single column's value from the first result of a query.
at line 3022
mixed
rawValue(string $expression, array $bindings = [])
Get a single expression value from the first result of a query.
at line 3037
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.
at line 3052
Collection
get(Expression|array|string $columns = ['*'])
Execute the query as a "select" statement.
at line 3068
protected array
runSelect()
Run the query as a "select" statement against the connection.
at line 3086
protected mixed
withoutFetchUsing(callable $callback)
Execute the given callback without custom fetch mode arguments.
at line 3104
protected Collection
withoutGroupLimitKeys(Collection $items)
Remove the group limit keys from the results in the collection.
at line 3133
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.
at line 3161
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.
at line 3184
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.
at line 3196
protected Collection
ensureOrderForCursorPagination(bool $shouldReverse = false)
Ensure the proper order by required for cursor pagination.
at line 3230
int
getCountForPagination(array $columns = ['*'])
Get the count of the total records for the paginator.
at line 3263
protected array
runPaginationCountQuery(array $columns = ['*'])
Run a pagination count query.
at line 3298
protected Builder
cloneForPaginationCount()
Clone the existing query instance for usage in a pagination subquery.
at line 3310
protected array
withoutSelectAliases(array $columns)
Remove the column aliases since they will break count queries.
at line 3324
LazyCollection
cursor()
Get a lazy collection for the given query.
at line 3352
protected void
enforceOrderBy()
Throw an exception if the query doesn't have an orderBy clause.
at line 3364
Collection
pluck(Expression|string $column, string|null $key = null)
Get a collection instance containing the values of a given column.
at line 3374
array
pluckWithColumn(Expression|string $column, string|null $key = null)
Get column values and the returned field name for Eloquent attribute conversion.
at line 3416
protected string|null
stripTableForPluck(Expression|string|null $column)
Strip off the table name or alias from a column identifier.
at line 3434
protected Collection
pluckFromObjectColumn(array $queryResult, string $column, string|null $key)
Retrieve column values from rows represented as objects.
at line 3454
protected Collection
pluckFromArrayColumn(array $queryResult, string $column, string|null $key)
Retrieve column values from rows represented as arrays.
at line 3474
string
implode(string $column, string $glue = '')
Concatenate values of a given column as a string.
at line 3482
bool
exists()
Determine if any rows exist for the current query.
at line 3507
bool
doesntExist()
Determine if no rows exist for the current query.
at line 3515
mixed
existsOr(Closure $callback)
Execute the given callback if no rows exist for the current query.
at line 3523
mixed
doesntExistOr(Closure $callback)
Execute the given callback if rows exist for the current query.
at line 3533
int
count(Expression|string $columns = '*')
Retrieve the "count" result of the query.
at line 3541
mixed
min(Expression|string $column)
Retrieve the minimum value of a given column.
at line 3549
mixed
max(Expression|string $column)
Retrieve the maximum value of a given column.
at line 3557
mixed
sum(Expression|string $column)
Retrieve the sum of the values of a given column.
at line 3567
mixed
avg(Expression|string $column)
Retrieve the average of the values of a given column.
at line 3575
mixed
average(Expression|string $column)
Alias for the "avg" method.
at line 3583
mixed
aggregate(string $function, array $columns = ['*'])
Execute an aggregate function on the database.
at line 3602
float|int
numericAggregate(string $function, array $columns = ['*'])
Execute a numeric aggregate function on the database.
at line 3630
protected Builder
setAggregate(string $function, array $columns)
Set the aggregate property without running the query.
at line 3654
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.
at line 3672
bool
insert(array $values)
Insert new records into the database.
at line 3712
int
insertOrIgnore(array $values)
Insert new records into the database while ignoring errors.
at line 3743
Collection
insertOrIgnoreReturning(array $values, array $returning = ['*'], array|string|null $uniqueBy = null)
Insert records while ignoring conflicts and return the inserted rows.
at line 3791
int|string
insertGetId(array $values, string|null $sequence = null)
Insert a new record and get the value of the primary key.
at line 3807
int
insertUsing(array $columns, Closure|Builder|Builder|Relation|string $query)
Insert new records into the table using a subquery.
at line 3824
int
insertOrIgnoreUsing(array $columns, Closure|Builder|Builder|Relation|string $query)
Insert new records into the table using a subquery while ignoring errors.
at line 3841
int
update(array $values)
Update records in the database.
at line 3876
int
updateFrom(array $values)
Update records in a PostgreSQL database using the update from syntax.
at line 3908
bool
updateOrInsert(array $attributes, array|callable $values = [])
Insert or update a record matching the attributes, and fill it with values.
at line 3934
int
upsert(array $values, array|string $uniqueBy, array|null $update = null)
Insert new records or update the existing ones.
at line 3983
int
increment(string $column, mixed $amount = 1, array $extra = [])
Increment a column's value by a given amount.
at line 4001
int
incrementEach(array $columns, array $extra = [])
Increment the given column's values by the given amounts.
at line 4024
int
decrement(string $column, mixed $amount = 1, array $extra = [])
Decrement a column's value by a given amount.
at line 4042
int
decrementEach(array $columns, array $extra = [])
Decrement the given column's values by the given amounts.
at line 4061
int
delete(mixed $id = null)
Delete records from the database.
at line 4083
void
truncate()
Run a "truncate" statement on the table.
at line 4095
Builder
newQuery()
Get a new instance of the query builder.
at line 4106
protected Builder
forSubQuery()
Create a new query instance for a sub-query.
at line 4116
array
getColumns()
Get all of the query builder's columns in a text-only array with all expressions evaluated.
at line 4126
Expression
raw(mixed $value)
Create a raw database expression.
at line 4134
protected Collection
getUnionBuilders()
Get the query builder instances that are used in the union of the query.
at line 4144
int|null
getLimit()
Get the "limit" value for the query or null if it's not set.
at line 4154
int|null
getOffset()
Get the "offset" value for the query or null if it's not set.
at line 4166
array
getBindings()
Get the current query value bindings in a flattened array.
at line 4176
array
getRawBindings()
Get the raw array of bindings.
at line 4189
Builder
setBindings(array $bindings, string $type = 'where')
Set the bindings on the query builder.
at line 4207
Builder
addBinding(mixed $value, string $type = 'where')
Add a binding to the query.
at line 4228
mixed
castBinding(mixed $value)
Cast the given binding value.
at line 4253
array
cleanBindings(array $bindings)
Remove all of the expressions from a list of bindings.
at line 4267
protected mixed
flattenValue(mixed $value)
Get a scalar type value from an unknown type of input.
at line 4275
protected string
defaultKeyName()
Get the default key name of the table.
at line 4283
ConnectionInterface
getConnection()
Get the database connection instance.
at line 4293
protected void
ensureConnectionSupportsVectors()
Ensure the database connection supports vector queries.
at line 4303
Processor
getProcessor()
Get the database query processor instance.
at line 4311
Grammar
getGrammar()
Get the query grammar instance.
at line 4319
Builder
useWritePdo()
Use the write connection when executing the query.
at line 4335
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.
at line 4345
protected bool
isQueryable(mixed $value)
Determine if the value is a query builder instance or a Closure.
at line 4358
protected void
ensureCanEmbedQuery(Builder $query)
Ensure the query can be embedded in another statement.
at line 4370
Builder
clone()
Clone the query.
at line 4378
Builder
cloneWithout(array $properties)
Clone the query without the given properties.
at line 4392
Builder
cloneWithoutBindings(array $except)
Clone the query without the given bindings.
at line 4404
Builder
dump(mixed ...$args)
Dump the current SQL and bindings.
at line 4418
Builder
dumpRawSql()
Dump the raw current SQL with embedded bindings.
at line 4428
never
dd()
Die and dump the current SQL and bindings.
at line 4436
never
ddRawSql()
Die and dump the current SQL with embedded bindings.
at line 4444
static void
flushState()
Flush all static state.