From 6b982ec2530e5cdd1a84336e72d13a4464982865 Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 21 Apr 2016 21:01:45 -0700 Subject: [PATCH] Check for accessories --- app/Http/Controllers/UsersController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index 0ea04f0537..49f688c8d6 100755 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -360,6 +360,12 @@ class UsersController extends Controller return Redirect::route('users')->with('error', 'This user still has ' . count($user->licenses) . ' licenses associated with them.'); } + if (count($user->accessories) > 0) { + + // Redirect to the user management page + return Redirect::route('users')->with('error', 'This user still has ' . count($user->accessories) . ' accessories associated with them.'); + } + // Delete the user $user->delete(); @@ -504,7 +510,7 @@ class UsersController extends Controller if (!Company::isCurrentUserHasAccess($user)) { return Redirect::route('users')->with('error', trans('general.insufficient_permissions')); } else { - + // Restore the user if (User::withTrashed()->where('id',$id)->restore()) { return Redirect::route('users')->with('success', trans('admin/users/message.success.restored'));