From 9b6726a630829c55f9b9271fb578d21ab0925c1e Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 28 Sep 2017 19:57:03 -0700 Subject: [PATCH] Fixes #4056 - check for assets before deleting user --- app/Http/Controllers/UsersController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index 62360ff51..31f374144 100755 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -376,6 +376,11 @@ class UsersController extends Controller return redirect()->route('users.index')->with('error', 'This user still has ' . $user->assets()->count() . ' assets associated with them.'); } + if (count($user->assets) > 0) { + // Redirect to the user management page + return redirect()->route('users.index')->with('error', 'This user still has ' . count($user->assets) . ' assets associated with them.'); + } + if ($user->licenses()->count() > 0) { // Redirect to the user management page return redirect()->route('users.index')->with('error', 'This user still has ' . $user->assets()->count() . ' assets associated with them.');