Information Technology Questions and Answers Community

Laravel Price Filter Wherebetween

I have price filter slider on my Laravel project and I am using Bootstrap slider.

 

Here is my input code on view

 

<input name="price" id="ex2" type="text" class="span2" value="" data-slider-min="10" data-slider-max="2000" data-slider-step="5" data-slider-value="[250,450]" onchange="checkBoxHandler()"/>

Here is my auto submit script on Javascript

 

<script> 

    function checkBoxHandler() { 

        $('#color_form').submit(); 

    } 

 

    $("#ex2").slider({});

</script>

Here is my controller

 

$price = $request->price;

if (request()->has('price')) {

    $products = product::whereBetween('price', [$price])

        ->whereHas('categories', function ($query) use ($tags){

            $query->where('name', $tags);

        })->paginate(20);

And I got the following error

 

SQLSTATE[HY093]: Invalid parameter number (SQL: select count(*) as aggregate from products where price between 250,1400 and swim and exists (select * from categories inner join category_product on categories.id = category_product.category_id where products.id = category_product.product_id and name = ?))

PHP         JQuery         twitter-bootstrap         laravel         laravel-5.4        
Your Answer: 

0 Answers
Edit Account
LOGIN INFORMATION
Change Settings
Email Notifications Notifications will be sent to abcd@gmail.com
Select option for your email notifications:
Mature / News Filter We'll send on email when new jobs are posted
Option 2 for email notification We'll send on email when new jobs are posted