trait Illuminate / Database / Concerns / BuildsQueries
You are viewing an older version of the documentation. For the latest, please visit master documentation.

BuildsQueries

Methods

public

chunk ( $count , callable $callback ) : bool

Chunk the results of the query.

Parameters

  • $count int
  • $callback callable
public

chunkMap ( callable $callback , $count ) : Collection

Run a map over each item while chunking.

Parameters

  • $callback callable
  • $count int
public

each ( callable $callback , $count ) : bool

Execute a callback over each item while chunking.

Parameters

  • $callback callable
  • $count int
public

chunkById ( $count , callable $callback , $column , $alias ) : bool

Chunk the results of a query by comparing IDs.

Parameters

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

eachById ( callable $callback , $count , $column , $alias ) : bool

Execute a callback over each item while chunking by ID.

Parameters

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

lazy ( $chunkSize ) : LazyCollection

Query lazily, by chunks of the given size.

Parameters

  • $chunkSize int
public

lazyById ( $chunkSize , $column , $alias ) : LazyCollection

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

Parameters

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

lazyByIdDesc ( $chunkSize , $column , $alias ) : LazyCollection

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

Parameters

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

orderedLazyById ( $chunkSize , $column , $alias , $descending ) : LazyCollection

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

Parameters

  • $chunkSize int
  • $column string|null
  • $alias string|null
  • $descending bool
public

first ( $columns ) : Model |object|static|null

Execute the query and get the first result.

Parameters

  • $columns array|string
public

sole ( $columns ) : Model |object|static|null

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

Parameters

  • $columns array|string
protected

paginateUsingCursor ( $perPage , $columns , $cursorName , $cursor ) : CursorPaginator

Paginate the given query using a cursor paginator.

Parameters

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

getOriginalColumnNameForCursorPagination ( $builder , string $parameter ) : string

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

Parameters

protected

paginator ( $items , $total , $perPage , $currentPage , $options ) : LengthAwarePaginator

Create a new length-aware paginator instance.

Parameters

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

simplePaginator ( $items , $perPage , $currentPage , $options ) : Paginator

Create a new simple paginator instance.

Parameters

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

cursorPaginator ( $items , $perPage , $cursor , $options ) : CursorPaginator

Create a new cursor paginator instance.

Parameters

public

tap ( $callback ) : $this|mixed

Pass the query to a given callback.

Parameters

  • $callback callable