Home > Enterprise >  how to get prices from the database using a price slider in jquery and laravel
how to get prices from the database using a price slider in jquery and laravel

Time:08-12

i have a jquery slider whereby on pushing a slider am able to get the minimum and maximum price values.using jquery am able to grab the value and send through ajax to an certain route.in the controller the values sent are processed whereby am able to get all the products within tht rice range of th values sent.the issue am getting is that the response sent back is for wrong prices.lets say for example i choose a price range of 2000 minimum price and 7000 maximum price,the prices sent back are in the above 7000 instead of the range between.

here is my code in the controller that fetches the prices

if(isset($data['startprice']) && !empty($data['startprice'])){
  Rental_house::select('monthly_rent','location_id','rental_name','rental_image')
            ->where('rental_status',1)->whereBetween('monthly_rent',[$request->startprice,$request->endprice]); 
            }

CodePudding user response:

You need to ensure that the column type used is numerically sortable, ie it needs to be a float or int type and not varchar.

  • Related