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!

Similar Posts

More content in Laravel category