Laravel查询数组

I am trying to create a eloquent query to get the user results of an array of user id's. Is there a clean way to accomplish this using elequent instead of chaining wheres like this:

$users = User::where('id', '=', '1')->orWhere('id','=','2')

My array of ids comes from an API call and can contain as many id's as the call passes.

Cheers!

You want to use whereIn. This lets you pass in an array of IDs.

$userIds = [1, 2];
$users = User::whereIn('id', $userIds)->get();