Laravel how to find the records between two different number. Like many times we need to find the product price greater than 15 and lower than 525. So how can write a query in Laravel? So it’s too easy to find the record between two number. Let’s see how to create a between condition on laravel eloquent.
<?php $product = Product::where('status', '=', 1) ->whereBetween('price', [15, 525]) ->get();
Or else you can use the ‘>’ and ‘<‘ condition for the getting same record instead of using ‘whereBetween’. let’s see how we can get the product price between greater than 15 and lower than 525.
<?php $product = Product::where('status', '=', 1) ->where('price','>=',15) ->where('price','<=',525) ->get();
you can use both of the conditions for getting the product price between 15 to 525.
If you face any issue after using this query please write the comment below.