public function deleteUser($id)
{
try {
// If multiple ids are specified
if ($id == 'multiple') {
$selected_ids = trim(Input::get('selected_ids'));
if ($selected_ids == '') {
throw new Exception('Nothing was selected to delete.');
}
$selected_ids = explode(' ', $selected_ids);
} else {
$selected_ids = array($id);
}
if (in_array(current_user()->id, $selected_ids)) {
throw new Exception('You can not delete yourself.');
}
foreach ($selected_ids as $id) {
// Delete the user using the user id
$user = Sentry::findUserById($id);
$user->delete();
}
$translation = count($selected_ids) > 1 ? 'users_delete' : 'user_delete';
$message = trans('success_messages.' . $translation);
return $message;
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
throw new Exception(trans('error_messages.users_find'));
}
}