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

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


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();


If you need by several params:

$ids = [1,2,3,4];$not_ids = [5,6,7,8];DB::table('table')->whereIn('id', $ids)                  ->whereNotIn('id', $not_ids)                  ->where('status', 1)                  ->get();