Illuminate\Support\Collection::forPage PHP Method

forPage() public method

"Paginate" the collection by slicing it into a smaller collection.
public forPage ( integer $page, integer $perPage ) : static
$page integer
$perPage integer
return static
    public function forPage($page, $perPage)
    {
        return $this->slice(($page - 1) * $perPage, $perPage);
    }

Usage Example

 /**
  * Paginate the results of this query
  *
  * @param  int
  * @param  int
  * @return $this
  */
 public function paginate($perPage, $page)
 {
     if ($perPage > 0) {
         $this->collection = $this->collection->forPage($page, $perPage);
     }
     return $this;
 }
All Usage Examples Of Illuminate\Support\Collection::forPage