page = static::page($total, $per_page); $this->last_page = ceil($total / $per_page); $this->per_page = $per_page; $this->results = $results; $this->total = $total; } /** * Get the current page from the request query string. * * The page will be validated and adjusted if it is less than one or greater than the last page. * * @param int $total * @param int $per_page * @return int */ public static function page($total, $per_page) { $page = Input::get('page', 1); if (is_numeric($page) and $page > $last_page = ceil($total / $per_page)) { return $last_page; } return (filter_var($page, FILTER_VALIDATE_INT) === false or $page < 1) ? 1 : $page; } /** * Create the HTML pagination links. * * @param int $adjacent * @return string */ public function links($adjacent = 3) { return ($this->last_page > 1) ? '