trait Illuminate / Database / Concerns / BuildsQueries
You're browsing the documentation for an upcoming version of Laravel. The documentation and features of this release are subject to change.

BuildsQueries

Methods

public

chunk ( $count , callable $callback ) : bool

Chunk the results of the query.

Parameters

  • $count int
  • $callback callable
public

chunkMap ( callable $callback , $count ) : Illuminate\...\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 ) : Illuminate\...\LazyCollection

Query lazily, by chunks of the given size.

Parameters

  • $chunkSize int
public

lazyById ( $chunkSize , $column , $alias ) : Illuminate\...\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 ) : Illuminate\...\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 ) : Illuminate\...\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|string
  • $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 Illuminate\...\Collection
  • $total int
  • $perPage int
  • $currentPage int
  • $options array
protected

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

Create a new simple paginator instance.

Parameters

  • $items Illuminate\...\Collection
  • $perPage int
  • $currentPage int
  • $options array
protected

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

Create a new cursor paginator instance.

Parameters

  • $items Illuminate\...\Collection
  • $perPage int
  • $cursor Cursor
  • $options array
public

tap ( $callback ) : $this

Pass the query to a given callback.

Parameters

  • $callback callable