1

If to use basic queries using use Illuminate\Support\Facades\DB; we get result as array instead collection. How to return collection?

$users = DB::select('select * from users where active = ?', [1]);

It returns array of $users (rows).

1
  • 1
    Just wrap this in collect()? Commented Nov 30, 2018 at 23:30

1 Answer 1

2

Wrapping your array of results using collect() should do it

collect($users);
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.