From 6529a75683692ed4f1d1f280ea8b073fbe6bf72f Mon Sep 17 00:00:00 2001 From: Ivan Nieto Vivanco Date: Wed, 6 Apr 2022 19:12:02 -0500 Subject: [PATCH] Update Assets locations when user's location changes whey they got bulk-edited --- app/Http/Controllers/Users/BulkUsersController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Users/BulkUsersController.php b/app/Http/Controllers/Users/BulkUsersController.php index b7ae6aac0e..5069b4a38a 100644 --- a/app/Http/Controllers/Users/BulkUsersController.php +++ b/app/Http/Controllers/Users/BulkUsersController.php @@ -109,12 +109,15 @@ class BulkUsersController extends Controller if (!$manager_conflict) { $this->conditionallyAddItem('manager_id'); } - - // Save the updated info User::whereIn('id', $user_raw_array) ->where('id', '!=', Auth::id())->update($this->update_array); + if(array_key_exists('location_id', $this->update_array)){ + Asset::where('assigned_type', User::class) + ->whereIn('assigned_to', $user_raw_array) + ->update(['location_id' => $this->update_array['location_id']]); + } // Only sync groups if groups were selected if ($request->filled('groups')) { foreach ($users as $user) {