Extend the Paginator’s Query String

LaravelPosted on

By default Laravel’s paginator does not follow the query strings when it’s generating URLs. It can be an issue when we perform a search and append the keywords in the query string, but the next page’s URL removes it entirely. With this snippet, you can extend the paginator’s URL and make your browsing fluent.

// Example link: posts?key=value&page=2
$paginator->append(['key' => 'value'])->links();

Need a web developer? Maybe we can help, get in touch!

Looking for web dev job?
You can check them on Jooble.

To see and write comments, you must allow the related (Disqus) cookies. For more information, please visit our privacy policy page.

Similar Posts

More content in Laravel category