Skip to content

Commit

Permalink
Merge pull request #14472 from snipe/fixes/last_audit_date_via_api
Browse files Browse the repository at this point in the history
Added validation for last_audit_date and next_audit_date
  • Loading branch information
snipe committed Mar 25, 2024
2 parents c4b7e77 + e9e6f92 commit 3f812f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/Http/Controllers/Api/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ public function store(StoreAssetRequest $request): JsonResponse
$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);
Expand Down Expand Up @@ -692,7 +692,7 @@ public function update(ImageUploadRequest $request, $id)
$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);
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public function declinedCheckout(User $declinedBy, $signature)
'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|after:last_audit_date',
'location_id' => 'nullable|exists:locations,id',
'rtd_location_id' => 'nullable|exists:locations,id',
'purchase_date' => 'nullable|date|date_format:Y-m-d',
Expand Down

0 comments on commit 3f812f6

Please sign in to comment.