BuildsQueries
trait BuildsQueries mixin TKey,
Traits
Methods
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Chunk the results of the query.
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.
Details
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.
at line 42
bool
chunk(int $count, callable $callback)
Chunk the results of the query.
at line 99
Collection
chunkMap(callable $callback, int $count = 1000)
Run a map over each item while chunking.
at line 117
bool
each(callable $callback, int $count = 1000)
Execute a callback over each item while chunking.
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.
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.
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.
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.
at line 245
LazyCollection
lazy(int $chunkSize = 1000)
Query lazily, by chunks of the given size.
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.
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.
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.
at line 385
null|TValue
first(array|string $columns = ['*'])
Execute the query and get the first result.
at line 398
TValue
firstOrFail(array|string $columns = ['*'], string|null $message = null)
Execute the query and get the first result or throw an exception.
at line 418
TValue
sole(array|string $columns = ['*'])
Execute the query and get the first result if it's the sole matching record.
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.
at line 538
protected string
getOriginalColumnNameForCursorPagination(Builder|Builder $builder, string $parameter)
Get the original column name of the given column, without any aliasing.
at line 560
protected LengthAwarePaginator
paginator(Collection $items, int $total, int $perPage, int $currentPage, array $options)
Create a new length-aware paginator instance.
at line 570
protected Paginator
simplePaginator(Collection $items, int $perPage, int $currentPage, array $options)
Create a new simple paginator instance.
at line 580
protected CursorPaginator
cursorPaginator(Collection $items, int $perPage, Cursor|null $cursor, array $options)
Create a new cursor paginator instance.
at line 593
BuildsQueries
tap(callable $callback)
Pass the query to a given callback and then return it.
at line 608
TReturn is null|TReturn)
pipe(callable $callback)
Pass the query to a given callback and return the result.