Use the form request on the UI controller

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-06-05 13:40:32 +01:00
parent 065a47a446
commit d4c080c7e4

View file

@ -343,39 +343,6 @@ class UsersController extends Controller
if ($user) { if ($user) {
// Check if we are not trying to delete ourselves
if ($user->id === Auth::id()) {
// Redirect to the user management page
return redirect()->route('users.index')
->with('error', trans('admin/users/message.error.cannot_delete_yourself'));
}
if (($user->assets()) && ($user->assets()->count() > 0)) {
// Redirect to the user management page
return redirect()->route('users.index')
->with('error', trans_choice('admin/users/message.error.delete_has_assets_var', $user->assets()->count(), ['count'=> $user->assets()->count()]));
}
if (($user->licenses()) && ($user->licenses()->count() > 0)) {
return redirect()->route('users.index')->with('error', trans_choice('admin/users/message.error.delete_has_licenses_var', $user->licenses()->count(), ['count'=> $user->licenses()->count()]));
}
if (($user->accessories()) && ($user->accessories()->count() > 0)) {
// Redirect to the user management page
return redirect()->route('users.index')->with('error', trans_choice('admin/users/message.error.delete_has_accessories_var', $user->accessories()->count(), ['count'=> $user->accessories()->count()]));
}
if (($user->managedLocations()) && ($user->managedLocations()->count() > 0)) {
// Redirect to the user management page
return redirect()->route('users.index')
->with('error', trans_choice('admin/users/message.error.delete_has_locations_var', $user->managedLocations()->count(), ['count'=> $user->managedLocations()->count()]));
}
if (($user->managesUsers()) && ($user->managesUsers()->count() > 0)) {
return redirect()->route('users.index')
->with('error', trans_choice('admin/users/message.error.delete_has_users_var', $user->managesUsers()->count(), ['count'=> $user->managesUsers()->count()]));
}
// Delete the user // Delete the user
$user->delete(); $user->delete();
return redirect()->route('users.index')->with('success', trans('admin/users/message.success.delete')); return redirect()->route('users.index')->with('success', trans('admin/users/message.success.delete'));