From 2910721ed668602d9f1a899c720ff6760e343e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Sanchez?= Date: Thu, 31 Jul 2014 16:43:29 +0200 Subject: [PATCH] QueryString is now appended to page links --- src/Pagination/IlluminatePaginatorAdapter.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Pagination/IlluminatePaginatorAdapter.php b/src/Pagination/IlluminatePaginatorAdapter.php index c19605aa..5026de2d 100644 --- a/src/Pagination/IlluminatePaginatorAdapter.php +++ b/src/Pagination/IlluminatePaginatorAdapter.php @@ -50,4 +50,32 @@ public function getCount() { return $this->count(); } + + /** + * Override method so includes work with pagination + * @param Int $page + * @return String + */ + public function getUrl($page) + { + $parameters = array( + $this->factory->getPageName() => $page, + ); + + // append the querystring to the pagination links + $queryStrings = array_except( \Input::query(), $this->factory->getPageName() ); + $this->appends($queryStrings); + + // If we have any extra query string key / value pairs that need to be added + // onto the URL, we will put them in query string form and then attach it + // to the URL. This allows for extra information like sortings storage. + if (count($this->query) > 0) + { + $parameters = array_merge($parameters, $this->query); + } + + $fragment = $this->buildFragment(); + + return $this->factory->getCurrentUrl().'?'.http_build_query($parameters, null, '&').$fragment; + } }