Are you using paginate in your query?
$model = Model::paginate(10);
I have a form which sends data to controller using GET method:
this is the route: Route::get('search',[MainController::class,'search'])->name('search');
The search function in the MainController receives data sent through the form and returns a variable ($result) like this:
return view('search',compact('result'));
in the view: @foreach ($result as $value) {{$value->title}} @endforeach
{{$result->links()}} Everythings looks good, but when I send the form I get the sent values on the browser like this: http://127.0.0.1:8000/search?cat=1&type=1&pay=2&order=2&search=
THE PROBLEM is that when I click on the pagination numbers to go to page 2,3, or any page the page shows all the data brought not just the ones I chose through the form, so instead of getting results on a certain cat, a certain type and so on, I get the whole results as if I didn't choose anything from the form and then the browser appears like this: http://127.0.0.1:8000/search?page=2 while it should appear like this: http://127.0.0.1:8000/search?cat=1&type=1&pay=2&order=2&search=&page=2
How can I solve this problem?
@yassemoh Seems like the query parameter is not available on the pagination.
Try this $result->withQueryString()->links() instead $result->links()
Please or to participate in this conversation.