BuildsQueries
Table of Contents
- chunk() : bool
- Chunk the results of the query.
- each() : bool
- Execute a callback over each item while chunking.
- first() : Model|object|static|null
- Execute the query and get the first result.
- tap() : Builder
- Pass the query to a given callback.
- unless() : mixed
- Apply the callback's query changes if the given "value" is false.
- when() : mixed
- Apply the callback's query changes if the given "value" is true.
- paginator() : LengthAwarePaginator
- Create a new length-aware paginator instance.
- simplePaginator() : Paginator
- Create a new simple paginator instance.
Methods
chunk()
Chunk the results of the query.
public
chunk(int $count, callable $callback) : bool
Parameters
- $count : int
- $callback : callable
Return values
bool —each()
Execute a callback over each item while chunking.
public
each(callable $callback[, int $count = 1000 ]) : bool
Parameters
- $callback : callable
- $count : int = 1000
Return values
bool —first()
Execute the query and get the first result.
public
first([array<string|int, mixed> $columns = ['*'] ]) : Model|object|static|null
Parameters
- $columns : array<string|int, mixed> = ['*']
Return values
Model|object|static|null —tap()
Pass the query to a given callback.
public
tap(Closure $callback) : Builder
Parameters
- $callback : Closure
Return values
Builder —unless()
Apply the callback's query changes if the given "value" is false.
public
unless(mixed $value, callable $callback[, callable $default = null ]) : mixed
Parameters
- $value : mixed
- $callback : callable
- $default : callable = null
Return values
mixed —when()
Apply the callback's query changes if the given "value" is true.
public
when(mixed $value, callable $callback[, callable $default = null ]) : mixed
Parameters
- $value : mixed
- $callback : callable
- $default : callable = null
Return values
mixed —paginator()
Create a new length-aware paginator instance.
protected
paginator(Collection $items, int $total, int $perPage, int $currentPage, array<string|int, mixed> $options) : LengthAwarePaginator
Parameters
- $items : Collection
- $total : int
- $perPage : int
- $currentPage : int
- $options : array<string|int, mixed>
Return values
LengthAwarePaginator —simplePaginator()
Create a new simple paginator instance.
protected
simplePaginator(Collection $items, int $perPage, int $currentPage, array<string|int, mixed> $options) : Paginator
Parameters
- $items : Collection
- $perPage : int
- $currentPage : int
- $options : array<string|int, mixed>