Reputation: 65
I have written a query to filter my products. This is my code:
$products = \DB::table('products')->select('*');
foreach ($request->all() as $cat => $subCat) {
if($subCat != '*') {
$products->where('id', $subCat);
}
}
$products->get();
However, the query returns a Builder object and I can't figure out why.
What is exactly wrong?
Thanks.
Upvotes: 1
Views: 516
Reputation: 34914
I doubt you haven't assign value into variable, try this
$products = $products->get();
Upvotes: 1