Can I do Model->where('id', ARRAY) multiple where conditions?

Vudew picture Vudew · Jun 8, 2015 · Viewed 114.3k times · Source

The title says it all.

I get that I can do this :

DB::table('items')->where('something', 'value')->get()

But what I want to check the where condition for multiple values like so:

DB::table('items')->where('something', 'array_of_value')->get()

Is there an easy way of doing this?

Answer

Limon Monte picture Limon Monte · Jun 8, 2015

There's whereIn():

$items = DB::table('items')->whereIn('id', [1, 2, 3])->get();