public function paginate($page = 1, $perPage = null, $columns = ['*'])
    {
        $perPage = $perPage ?: $this->defaultPageSize;

        $query = $this->getQuery();

        $total = $query->getQuery()->getCountForPagination($columns);
        $query->getQuery()->forPage($page, $perPage);
        $results = $query->get($columns);

        $results = new LengthAwarePaginator($results, $total, $perPage, $page);

        return $this->returnResults($results);
    }
public function paginate($page = 1, $perPage = null, $columns = ['*'])
    {
        $perPage = $perPage ?: $this->defaultPageSize;

        $query = $this->getQuery();

        $total = $query->getQuery()->getCountForPagination($columns);
        $query->getQuery()->forPage($page, $perPage);
        $results = $query->get($columns);

        $results = new LengthAwarePaginator($results, $total, $perPage, $page);

        return $this->returnResults($results);
    }
public function paginate ( $ page = 1 , $ perPage = null , $ columns = [ '*' ] ) { $ perPage = $ perPage ? : $ this -> defaultPageSize ; $ query = $ this -> getQuery ( ) ; $ total = $ query -> getQuery ( ) -> getCountForPagination ( $ columns ) ; $ query -> getQuery ( ) -> forPage ( $ page , $ perPage ) ; $ results = $ query -> get ( $ columns ) ; $ results = new LengthAwarePaginator ( $ results , $ total , $ perPage , $ page ) ; return $ this -> returnResults ( $ results ) ; }
Paginate a given query

@param int $page
@param int $perPage
@param array $columns
@return mixed
Paginate a given query