From e5653eaa93b2f7ba2f590205ac85650334d34af9 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 15 May 2024 14:21:01 +0100 Subject: [PATCH] Save new data Signed-off-by: snipe --- app/Http/Controllers/Assets/AssetsController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 20a5564a44..c1386f81f1 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -308,7 +308,8 @@ class AssetsController extends Controller $asset->status_id = $request->input('status_id', null); $asset->warranty_months = $request->input('warranty_months', null); $asset->purchase_cost = $request->input('purchase_cost', null); - $asset->purchase_date = $request->input('purchase_date', null); + $asset->purchase_date = $request->input('purchase_date', null); + $asset->next_audit_date = $request->input('next_audit_date', null); if ($request->filled('purchase_date') && !$request->filled('asset_eol_date') && ($asset->model->eol > 0)) { $asset->purchase_date = $request->input('purchase_date', null); $asset->asset_eol_date = Carbon::parse($request->input('purchase_date'))->addMonths($asset->model->eol)->format('Y-m-d'); @@ -888,12 +889,12 @@ class AssetsController extends Controller // Check to see if they checked the box to update the physical location, // not just note it in the audit notes if ($request->input('update_location') == '1') { - Log::debug('update location in audit'); $asset->location_id = $request->input('location_id'); } - if ($asset->save()) { + if ($asset->isValid() && $asset->save()) { + $file_name = ''; // Upload an image, if attached if ($request->hasFile('image')) { @@ -911,6 +912,8 @@ class AssetsController extends Controller $asset->logAudit($request->input('note'), $request->input('location_id'), $file_name); return redirect()->route('assets.audit.due')->with('success', trans('admin/hardware/message.audit.success')); } + + return redirect()->back()->withInput()->withErrors($asset->getErrors()); } public function getRequestedIndex($user_id = null)