1

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.

1
  • 1
    What you get in $request->all() ? .Also share complete code how you return value ? Commented Nov 23, 2017 at 16:57

1 Answer 1

1

I doubt you haven't assign value into variable, try this

$products = $products->get();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.