Illuminate\Database\Query\Builder::forPageAfterId PHP Method

forPageAfterId() public method

Constrain the query to the next "page" of results after a given ID.
public forPageAfterId ( integer $perPage = 15, integer $lastId, string $column = 'id' ) : Builder | static
$perPage integer
$lastId integer
$column string
return Builder | static
    public function forPageAfterId($perPage = 15, $lastId = 0, $column = 'id')
    {
        $this->orders = Collection::make($this->orders)->reject(function ($order) use($column) {
            return $order['column'] === $column;
        })->values()->all();
        return $this->where($column, '>', $lastId)->orderBy($column, 'asc')->take($perPage);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Constrain the query to the next "page" of results after a given ID.
  *
  * @param int $perPage
  * @param int $lastId
  * @param string $column
  * @return \Illuminate\Database\Query\Builder|static 
  * @static 
  */
 public static function forPageAfterId($perPage = 15, $lastId = 0, $column = 'id')
 {
     return \Illuminate\Database\Query\Builder::forPageAfterId($perPage, $lastId, $column);
 }