conditionally fixed redirect select option

This commit is contained in:
Godfrey M
2024-05-21 14:08:35 -07:00
parent 0327e71f0f
commit f2693ee957
4 changed files with 13 additions and 11 deletions
@@ -13,6 +13,7 @@ use App\Models\LicenseSeat;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\View;
class AssetCheckinController extends Controller
@@ -122,10 +123,12 @@ class AssetCheckinController extends Controller
$acceptance->delete();
});
Session::put('redirect_option', $request->get('redirect_option'));
// Was the asset updated?
if ($asset->save()) {
event(new CheckoutableCheckedIn($asset, $target, Auth::user(), $request->input('note'), $checkin_at, $originalValues));
return Helper::getRedirectOption($request, $assetId);
return Helper::getRedirectOption($asset, $assetId, 'Assets');
}
// Redirect to the asset management page with error
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.checkin.error').$asset->getErrors());
@@ -99,13 +99,11 @@ class AssetCheckoutController extends Controller
return redirect()->to("hardware/$assetId/checkout")->with('error', trans('general.error_user_company'));
}
}
$redirect_option = $request->get('redirect_option');
if($redirect_option != Session::get('redirect_option')) {
Session::put(['redirect_option' => $redirect_option, 'checkout_to_type' => $request->get('checkout_to_type')]);
}
Session::put(['redirect_option' => $request->get('redirect_option'), 'checkout_to_type' => $request->get('checkout_to_type')]);
if ($asset->checkOut($target, $admin, $checkout_at, $expected_checkin, $request->get('note'), $request->get('name'))) {
return Helper::getRedirectOption($request, $assetId);
return Helper::getRedirectOption($request, $assetId, 'Assets');
}
// Redirect to the asset management page with error
return redirect()->to("hardware/$assetId/checkout")->with('error', trans('admin/hardware/message.checkout.error').$asset->getErrors());