From 546c3e50fa71152254349b12448cb9f6e7ee1e8c Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 30 Oct 2017 19:33:52 -0700 Subject: [PATCH] =?UTF-8?q?Fixed=20updating=20the=20assigned=20assets=20lo?= =?UTF-8?q?cation=20if=20user=E2=80=99s=20location=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/UsersController.php | 3 +++ app/Http/Controllers/UsersController.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 362e9c7141..22f0acc25c 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -229,6 +229,9 @@ class UsersController extends Controller $user->password = bcrypt($request->input('password')); } + // Update the location of any assets checked out to this user + Asset::where('assigned_type', User::class) + ->where('assigned_to', $user->id)->update(['location_id' => $request->input('location_id', null)]); if ($user->save()) { return response()->json(Helper::formatStandardApiResponse('success', (new UsersTransformer)->transformUser($user), trans('admin/users/message.success.update'))); diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index 354fd17765..e592d3b02d 100755 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -331,6 +331,9 @@ class UsersController extends Controller $user->zip = $request->input('zip', null); + // Update the location of any assets checked out to this user + Asset::where('assigned_type', User::class) + ->where('assigned_to', $user->id)->update(['location_id' => $request->input('location_id', null)]); // Do we want to update the user password? if ($request->has('password')) {