trait BuildsQueries (View source)

Methods

bool
chunk(int $count, callable $callback)

Chunk the results of the query.

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
eachById(callable $callback, int $count = 1000, string|null $column = null, string|null $alias = null)

Execute a callback over each item while chunking by id.

Model|object|BuildsQueries|null
first(array|string $columns = ['*'])

Execute the query and get the first result.

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

Apply the callback's query changes if the given "value" is true.

$this
tap(callable $callback)

Pass the query to a given callback.

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

Apply the callback's query changes if the given "value" is false.

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.

Details

bool chunk(int $count, callable $callback)

Chunk the results of the query.

Parameters

int $count
callable $callback

Return Value

bool

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

Execute a callback over each item while chunking.

Parameters

callable $callback
int $count

Return Value

bool

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

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

Model|object|BuildsQueries|null first(array|string $columns = ['*'])

Execute the query and get the first result.

Parameters

array|string $columns

Return Value

Model|object|BuildsQueries|null

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

Apply the callback's query changes if the given "value" is true.

Parameters

mixed $value
callable $callback
callable|null $default

Return Value

mixed|$this

$this tap(callable $callback)

Pass the query to a given callback.

Parameters

callable $callback

Return Value

$this

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

Apply the callback's query changes if the given "value" is false.

Parameters

mixed $value
callable $callback
callable|null $default

Return Value

mixed|$this

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

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