public function performCountQuery(QueryBuilder $countQuery, $querySql, $queryBindings, $page)
    {
        //grab the model instance
        $model = $this->config->getDataModel();

        //then wrap the inner table and perform the count
        $sql = "SELECT COUNT({$model->getKeyName()}) AS aggregate FROM ({$querySql}) AS agg";

        //then perform the count query
        $results = $countQuery->getConnection()->select($sql, $queryBindings);
        $numRows = is_array($results[0]) ? $results[0]['aggregate'] : $results[0]->aggregate;
        $page    = (int) $page;
        $last    = (int) ceil($numRows / $this->rowsPerPage);

        return array(
            //if the current page is greater than the last page, set the current page to the last page
            'page'  => $page > $last ? $last : $page,
            'last'  => $last,
            'total' => $numRows,
        );
    }
public function performCountQuery(QueryBuilder $countQuery, $querySql, $queryBindings, $page)
    {
        //grab the model instance
        $model = $this->config->getDataModel();

        //then wrap the inner table and perform the count
        $sql = "SELECT COUNT({$model->getKeyName()}) AS aggregate FROM ({$querySql}) AS agg";

        //then perform the count query
        $results = $countQuery->getConnection()->select($sql, $queryBindings);
        $numRows = is_array($results[0]) ? $results[0]['aggregate'] : $results[0]->aggregate;
        $page    = (int) $page;
        $last    = (int) ceil($numRows / $this->rowsPerPage);

        return array(
            //if the current page is greater than the last page, set the current page to the last page
            'page'  => $page > $last ? $last : $page,
            'last'  => $last,
            'total' => $numRows,
        );
    }
public function performCountQuery ( QueryBuilder $ countQuery , $ querySql , $ queryBindings , $ page ) { //grab the model instance $ model = $ this -> config -> getDataModel ( ) ; //then wrap the inner table and perform the count $ sql = "SELECT COUNT({$model->getKeyName()}) AS aggregate FROM ({$querySql}) AS agg" ; //then perform the count query $ results = $ countQuery -> getConnection ( ) -> select ( $ sql , $ queryBindings ) ; $ numRows = is_array ( $ results [ 0 ] ) ? $ results [ 0 ] [ 'aggregate' ] : $ results [ 0 ] -> aggregate ; $ page = ( int ) $ page ; $ last = ( int ) ceil ( $ numRows / $ this -> rowsPerPage ) ; return array ( //if the current page is greater than the last page, set the current page to the last page 'page' => $ page > $ last ? $ last : $ page , 'last' => $ last , 'total' => $ numRows , ) ; }
Performs the count query and returns info about the pages.

@param \Illuminate\Database\Query\Builder $countQuery
@param string                             $querySql
@param array                              $queryBindings
@param int                                $page

@return array
Performs the count query and returns info about the pages .