In this tutorial we are going to learn about Products Filter By Price.
So let see how can filter products by price.
Go to the ShopController and inside this index function
Create a variable for price range and assign the value from query string as following


public function index(Request $request)
{
$prange = $request->query("prange");
if(!$prange)
$prange = "0,500";
$from = explode(",",$prange)[0];
$to = explode(",",$prange)[1];
$products = Product::where(function($query) use($q_brands){
$query->whereIn('brand_id',explode(',',$q_brands))->orWhereRaw("'".$q_brands."'=''");
})
->where(function($query) use($q_categories){
$query->whereIn('category_id',explode(',',$q_categories))->orWhereRaw("'".$q_categories."'=''");
})
->whereBetween('regular_price',array($from,$to))
->orderBy('created_at','DESC')->orderBy($o_column,$o_order)->paginate($size);
return view('shop',['products'=>$products,'page'=>$page,'size'=>$size,'order'=>$order,'brands'=>$brands,'q_brands'=>$q_brands,'categories'=>$categories,'q_categories'=>$q_categories,'from'=>$from,'to'=>$to]);
}


Now go to the shop.blade.php file and add hidden field in filter form


<input type="hidden" name="prange" id="prange" value="" />


Now add javascript function inside the push directive as following


<script>
$(function(){

var $range = $(".js-range-slider");
instance = $range.data("ionRangeSlider");
instance.update({
from:{{$from}},
to:{{$to}}
});

$("#prange").on("change",function(){
setTimeout(()=>{
$("#frmFilter").submit();
},1000);
});
});
</script>


Now its done so lets check it
So switch to the browser and just refresh the page
Now lets slide the price range slider
And her you can see the all products between this price range
Now set another price range
So in this way you can Filter the products by Price.