I have users and roles relationship as belongsToMany. I now want to get all users have multiple roles by names.
I have tried as,
$role_ids = [1,2];
$users = User::whereHas('roles' , function ($query) use($role_ids) {
$query->whereIn('roles.id', $role_ids);
})->get();
But this approach gives me users who are associated with both or either one roles which is not i am expecting