/** * Get paginated model results as a Paginator instance. * * @param int $per_page * @return Paginator */ private function _paginate($per_page = null) { $total = $this->query->count(); // The number of models to show per page may be specified as a static property // on the model. The models shown per page may also be overriden for the model // by passing the number into this method. If the models to show per page is // not available via either of these avenues, a default number will be shown. if (is_null($per_page)) { $per_page = property_exists(get_class($this), 'per_page') ? static::$per_page : 20; } return Paginator::make($this->for_page(Paginator::page($total, $per_page), $per_page)->get(), $total, $per_page); }
/** * Get paginated model results as a Paginator instance. * * @param int $per_page * @return Paginator */ private function _paginate($per_page = null, $columns = array('*')) { $countCol = str_replace('.*', '.id', $columns[0], $exists); if ($exists) { $total = $this->query->count($countCol); } else { $total = $this->query->count(); } // The number of models to show per page may be specified as a static property // on the model. The models shown per page may also be overriden for the model // by passing the number into this method. If the models to show per page is // not available via either of these avenues, a default number will be shown. if (is_null($per_page)) { $per_page = property_exists(get_class($this), 'per_page') ? static::$per_page : 20; } return Paginator::make($this->select($columns)->distinct($columns)->for_page(Paginator::page($total, $per_page), $per_page)->get(), $total, $per_page); }