3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-03-29 20:04:21 +00:00

Prevent to delete a user if still has consumables associated to them

This commit is contained in:
Ivan Nieto Vivanco
2022-08-11 17:01:52 -05:00
parent c7d9baad8e
commit db53a00d3f
2 changed files with 10 additions and 0 deletions

View File

@ -348,6 +348,12 @@ class UsersController extends Controller
->with('error', 'This user still has '.$accessoriesCount.' accessories associated with them.');
}
if (($user->consumables()) && (($consumablesCount = $user->consumables()->count())) > 0) {
// Redirect to the user management page
return redirect()->route('users.index')
->with('error', 'This user still has '.$consumablesCount.' consumables associated with them.');
}
if (($user->managedLocations()) && (($managedLocationsCount = $user->managedLocations()->count())) > 0) {
// Redirect to the user management page
return redirect()->route('users.index')