I have url generated from pagination:
$next = $articles->nextPageUrl();
However this new url always leads to redirect. For SEO reasons i need to put there final url (generated after all redirects). How can i achieve this properly in Laravel?
E.g. Url generated by nextPageUrl() is /page/83?page=4
, however it redirects to /blog?page=4
. I should somehow get /blog?page=4
.
How can i achieve this properly in Laravel?
3
Answers
Using
$articles->lastPage()
paginator method.https://laravel.com/docs/5.6/pagination#paginator-instance-methods
In this method you need to declare input type Page
Example :
Just follow this Steps
In your Controller
Just change $request get to whatever you want
One way to do this would be to manually trace the redirect (5.4 version syntax):
This approach wouldn’t fit if the called functions aren’t pure (does any DB persisting, etc).