public function leave($userIds)
{
/** @var UserInterface[] $users */
$users = $this->users()->whereIn('id', (array) $userIds)->with(['groups', 'emails'])->get();
$ratings = array_pluck($users, 'rating');
if (in_array(Rating::SUPER, $ratings)) {
throw new CannotDeleteUserHavingSuperRatingException();
}
// delete user's emails
$this->emails()->deleteByUserIds($userIds);
$this->pendingEmails()->deleteByUserIds($userIds);
// delete user's accounts
$this->accounts()->deleteByUserIds($userIds);
// resolve group
foreach ($users as $user) {
// except user from user's groups
$user->groups()->detach();
$user->delete();
}
// todo: remove profile image
}