I have a small table and try to use some filters to get some specific data out of it.
My attempt:
$matchingCars = Car::where([
['brand', '=', request('brand')],
['model', '=', request('model')],
['price', '<', request('maxPrice')],
])->get();
Result:
Collection {#249 ▼
#items: []
}
You can see nothing is returned. However, if I do the queries one by one and count the result, then I get a number higher than 0, so there are models who pass my filters!
$checkBrands = Car::where('brand', '=', request('brand'))->get();
$checkModels = Car::where('model', '=', request('model'))->get();
$checkPrice = Car::where('price', '<', request('maxPrice'))->get();
echo count($checkBrands) . "<br>"; //output: 1
echo count($checkModels). "<br>"; //output: 1
echo count($checkPrice). "<br>"; //output: 8
die;
Why are they not stored in the collection?