From adf6e7d1cd7c2f9164743263c0c5f079d9aae834 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 7 Sep 2018 18:25:58 -0700 Subject: [PATCH] Added group support for user API --- app/Http/Controllers/Api/UsersController.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 1970640c78..5bd825d957 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -200,6 +200,12 @@ class UsersController extends Controller $user->password = bcrypt($request->get('password', $tmp_pass)); if ($user->save()) { + if ($request->has('groups')) { + $user->groups()->sync($request->input('groups')); + } else { + $user->groups()->sync(array()); + } + return response()->json(Helper::formatStandardApiResponse('success', (new UsersTransformer)->transformUser($user), trans('admin/users/message.success.create'))); } return response()->json(Helper::formatStandardApiResponse('error', null, $user->getErrors()));