1
votes

I'm using Laravel Scout to search for objects in my database, and need to have the results paginated, but Scout is automatically including a 'query' query term in the url in addition to the page number instead of just the page number.

I'm using the Scout built in pagination like so: $page_results = Page::search($validatedData['search_terms'])->paginate(10, 'page_results');

The problem is that instead of just getting the page number as a query, I'm also getting another 'query' stuck in there as well: http://192.168.10.10/wiki/search?query=a&page_results=2

As my route is like this: Route::post('/search', 'SearchController@search'); Its not expecting that query and is sending it to the fallback.

Is there a way to remove the 'query' query from the Scout links()? What I would like ideally is the following as I've got pagination working on other pages just fine by using the Eloquent pagination which doesn't include that extra query term: http://192.168.10.10/wiki/search?page_results=2

Any help would be much appreciated!

2
I think that's how the pagination works. you need to change the POST request to GET request in the route.Ropali Munshi
Have you found a solution for that?berkayk

2 Answers

0
votes

This should do the trick...

$page_results->withPath('results');

Laravel Pagination

0
votes

A solution could be to remove query from query string by calling ->appends('query', null) on your ->paginate() method.

There is closed issue on github about this.