W
W
WotanWeb2020-05-22 13:23:30
Laravel
WotanWeb, 2020-05-22 13:23:30

Is it possible to pass an array of conditions to whereIn in eloquent?

Good afternoon! Can you please tell me how can I pass an array to whereIn?
For a regular where, you can do this:

$conditions = array(
    array('email', '=', '[email protected]'),
    array('status', '=', 'active'),
);
$result = DB::table('users')->where($conditions)->get();


But for whereIn this is not possible, but I would like to be able to pass an array of several conditions there. It can be done?
And ideally, can you tell me if there is an opportunity in the usual where to use conditions like xxx in array?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya, 2020-05-22
@New_Horizons

I don't really understand what you need, but MB like this:

\DB::table('users')->where('status', '=', 'active')->whereIn('email', $emails)->get();

E
Eugene, 2020-05-22
@Nc_Soft

You can't do that, calm down.
https://laravel.com/docs/7.x/queries#where-clauses
Need to add whereIn

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question