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.
$request->all()? .Also share complete code how you return value ?