From 828b84084d00761d41b6fb8787919d59ff04c19f Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 21 Mar 2024 18:29:38 +0000 Subject: [PATCH] Added validation for last_audit_date and next_audit_date Signed-off-by: snipe --- app/Http/Controllers/Api/AssetsController.php | 4 ++-- app/Models/Asset.php | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index b26887b6ce..c672781e6f 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -613,7 +613,7 @@ class AssetsController extends Controller $asset->image = $asset->getImageUrl(); } - return response()->json(Helper::formatStandardApiResponse('success', $asset, trans('admin/hardware/message.create.success'))); + return response()->json(Helper::formatStandardApiResponse('success', (new AssetsTransformer)->transformAsset($asset), trans('admin/hardware/message.create.success'))); } return response()->json(Helper::formatStandardApiResponse('error', null, $asset->getErrors()), 200); @@ -692,7 +692,7 @@ class AssetsController extends Controller $asset->image = $asset->getImageUrl(); } - return response()->json(Helper::formatStandardApiResponse('success', $asset, trans('admin/hardware/message.update.success'))); + return response()->json(Helper::formatStandardApiResponse('success', (new AssetsTransformer)->transformAsset($asset), trans('admin/hardware/message.update.success'))); } return response()->json(Helper::formatStandardApiResponse('error', null, $asset->getErrors()), 200); diff --git a/app/Models/Asset.php b/app/Models/Asset.php index c2a2a8d995..981d785251 100644 --- a/app/Models/Asset.php +++ b/app/Models/Asset.php @@ -97,6 +97,8 @@ class Asset extends Depreciable 'warranty_months' => 'nullable|numeric|digits_between:0,240', 'last_checkout' => 'nullable|date_format:Y-m-d H:i:s', 'expected_checkin' => 'nullable|date', + 'last_audit_date' => 'nullable|date_format:Y-m-d H:i:s', + 'next_audit_date' => 'nullable|date|date_format:Y-m-d', 'location_id' => 'nullable|exists:locations,id', 'rtd_location_id' => 'nullable|exists:locations,id', 'purchase_date' => 'nullable|date|date_format:Y-m-d',