I'm implementing manual pagination using the LenghtAwarePagination class and it works but when I use:
{{ $result->links() }}
in the search
view, it generates the links without taking the current URL into account. Like this:
<ul>
<li><a href="/">1</a></li>
<li><a href="/?page=2">2</a></li>
<li><a href="/?page=3">3</a></li>
<li><a href="/?page=4">4</a></li>
</ul>
So, the URL is like this:
mypage.com/search/63.231237/12.4491092/?filter=true&filter2=true
I think it would be too much trouble to append each parameter one by one to the pagination links so how can I take whatever is after mypage.com
, in this case this:
/search/63.231237/12.4491092/?filter=true&filter2=true
. So I need to replace this:
/
/?page=2
/?page=3
/?page=4
for this:
/search/63.231237/12.4491092/?filter=true&filter2=true
/search/63.231237/12.4491092/?filter=true&filter2=true&page=2
/search/63.231237/12.4491092/?filter=true&filter2=true&page=3
/search/63.231237/12.4491092/?filter=true&filter2=true&page=4
How can I do it from within the links function?
EDIT: I got it to work using this:
$currentURL = $_SERVER["REQUEST_URI"];
$result= $this->paginate($results)->withPath($currentURL);
But there's a problem, I need to strip page=x
out of $currentURL
, how can I do that?