Can I do Model->where('id', ARRAY) multiple where conditions?
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?
There's whereIn()
:
$items = DB::table('items')->whereIn('id', [1, 2, 3])->get();
You could use one of the below solutions:
$items = Item::whereIn('id', [1,2,..])->get();
or:
$items = DB::table('items')->whereIn('id',[1,2,..])->get();