Level 70
I guess you can use the appends to pass data.
{{ $properties->appends(['queryOptions' => $query ])->links() }}
Check more- https://laravel.com/docs/master/pagination
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello
I'm trying to filter homes by Price Ascending, Price Descending, Most Recent, A-Z, Z-A and I've have success with exception to the fact that the queries to not persist after the first page. Can anyone please show me a way to do it?
public function index(Request $request)
{
$query = $request->input('queryOptions');
if($query == 'Price Ascending'){
$properties = Property::orderBy('price', 'asc');
}
if($query == 'Price Descending'){
$properties = Property::orderBy('price', 'desc');
}
if($query == 'Most Recent'){
$properties = Property::latest();
}
if($query == 'A-Z'){
$properties = Property::orderBy('city', 'asc');
}
if($query == 'Most Recent'){
$properties = Property::latest();
}
$properties = $properties->paginate(10);
return view('property.index', compact('properties', 'query'));
}
I guess you can use the appends to pass data.
{{ $properties->appends(['queryOptions' => $query ])->links() }}
Check more- https://laravel.com/docs/master/pagination
Please or to participate in this conversation.