Have you thought of putting some queries in an if else condition.
Eloquent query
Hi I have a filter named prices when the user clicks on say Less than 20 check box all the products should filter through a table named product_prices_inventory_tax. So when the user checks the checkbox related to price range It sends an array of the price range.
say I clicked on Less than 20 then I get
Array
(
[price_array] => Array
(
[0] => 0,20
)
)
when user check a price range 21 - 50 then it would return an array
Array
(
[price_array] => Array
(
[0] => 0,20
[1] => 21,50
)
)
So I want to query my PricesInventoryTax model where I would dynamically able to query. The query I made is this
$productsPrice = ProductPricesInventoryTax::where('sale_price', '>=', $min_price)
->where('sale_price', '<=', $max_price)
->get();
The challenge is this would work for one price range say 0, 20. I can find the smallest and the largest value from this but what would i do when I get another array f price range ? How will I add another query say I want to find products ranging from 0,20 as well as 30,40 ?
Please or to participate in this conversation.