Refactor helper method for redirection

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-07-25 22:02:03 +01:00
parent 73a80a5fbc
commit 018b5684fc

View file

@ -1494,7 +1494,7 @@ class Helper
if ($redirect_option == 'index') { if ($redirect_option == 'index') {
switch ($table) { switch ($table) {
case "Assets": case "Assets":
return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.checkout.success')); return route('hardware.index');
} }
} }
@ -1502,7 +1502,7 @@ class Helper
if ($redirect_option == 'item') { if ($redirect_option == 'item') {
switch ($table) { switch ($table) {
case "Assets": case "Assets":
return redirect()->route('hardware.show', $id ? $id : $asset_id)->with('success', trans('admin/hardware/message.checkout.success')); return route('hardware.show', $id ?? $asset_id);
} }
} }
@ -1510,11 +1510,12 @@ class Helper
if ($redirect_option == 'target') { if ($redirect_option == 'target') {
switch ($checkout_to_type) { switch ($checkout_to_type) {
case 'user': case 'user':
return redirect()->route('users.show', $request->assigned_user)->with('success', trans('admin/hardware/message.checkout.success')); \Log::error('We think the checkout type is user?');
return route('users.show', $request->assigned_user);
case 'location': case 'location':
return redirect()->route('locations.show', $request->assigned_location)->with('success', trans('admin/hardware/message.checkout.success')); return route('locations.show', $request->assigned_location);
case 'asset': case 'asset':
return redirect()->route('hardware.show', $request->assigned_asset)->with('success', trans('admin/hardware/message.checkout.success')); return route('hardware.show', $request->assigned_asset);
} }
} }
return redirect()->back()->with('error', trans('admin/hardware/message.checkout.error')); return redirect()->back()->with('error', trans('admin/hardware/message.checkout.error'));