per_page = $per_page; $this->results = $results; $this->total = $total; // Validate and set the current page. If the given page is greater than the last page, the // current page will be set to the last page. If the given page is not an integer or is less // than 1, the current page will be set to 1. $this->page = static::page($this->last_page()); } /** * Get the current page from the request query string. * * @param int $last_page * @return int */ public static function page($last_page) { $page = Input::get('page', 1); if (is_numeric($page) and $page > $last_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) { if ($this->last_page() > 1) { return '