public function paginate($perPage = 15, $page = null, $options = [], $setPath = null)
    {
        $page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
        $items = ($this instanceof Collection || $this instanceof PostCollection) ? $this : Collection::make($this);
        $paginator = new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options);

        // Set Path
        if(is_null($setPath)) {
            $paginator->setPath(\Request::url());
        }else{
            $paginator->setPath($setPath);
        }
        return $paginator;
    }
public function paginate($perPage = 15, $page = null, $options = [], $setPath = null)
    {
        $page = $page ?: (Paginator::resolveCurrentPage() ?: 1);
        $items = ($this instanceof Collection || $this instanceof PostCollection) ? $this : Collection::make($this);
        $paginator = new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options);

        // Set Path
        if(is_null($setPath)) {
            $paginator->setPath(\Request::url());
        }else{
            $paginator->setPath($setPath);
        }
        return $paginator;
    }
public function paginate ( $ perPage = 15 , $ page = null , $ options = [ ] , $ setPath = null ) { $ page = $ page ? : ( Paginator :: resolveCurrentPage ( ) ? : 1 ) ; $ items = ( $ this instanceof Collection || $ this instanceof PostCollection ) ? $ this : Collection :: make ( $ this ) ; $ paginator = new LengthAwarePaginator ( $ items -> forPage ( $ page , $ perPage ) , $ items -> count ( ) , $ perPage , $ page , $ options ) ; // Set Path if ( is_null ( $ setPath ) ) { $ paginator -> setPath ( \ Request :: url ( ) ) ; } else { $ paginator -> setPath ( $ setPath ) ; } return $ paginator ; }
Create a pagination of items from array or collection.

@param  int   $perPage
@param  null  $page
@param  array $options
@param  null  $setPath
@return LengthAwarePaginator
Create a pagination of items from array or collection .