/** * Get paginated model results. * * @param int $per_page * @return Paginator */ private function _paginate($per_page = null) { $total = $this->query->count(); 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 * @param array $columns * @return Paginator */ private function _paginate($per_page = null, $columns = array('*')) { list($orderings, $this->query->orderings) = array($this->query->orderings, null); $total = $this->query->count(); $this->query->orderings = $orderings; // 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($columns), $total, $per_page); }
/** * Make sure the soft-filter is added to count() calls */ public function count($column = null, $distinct = true) { $this->add_soft_filter(); return parent::count($column, $distinct); }