diff --git a/app/Http/Requests/StoreAssetRequest.php b/app/Http/Requests/StoreAssetRequest.php index 20b801a52c..70e7195c7d 100644 --- a/app/Http/Requests/StoreAssetRequest.php +++ b/app/Http/Requests/StoreAssetRequest.php @@ -29,19 +29,7 @@ class StoreAssetRequest extends ImageUploadRequest ? Company::getIdForCurrentUser($this->company_id) : $this->company_id; - if ($this->input('last_audit_date')) { - try { - $lastAuditDate = Carbon::parse($this->input('last_audit_date')); - - $this->merge([ - 'last_audit_date' => $lastAuditDate->startOfDay()->format('Y-m-d H:i:s'), - ]); - } catch (InvalidFormatException $e) { - // we don't need to do anything here... - // we'll keep the provided date in an - // invalid format so validation picks it up later - } - } + $this->formatLastAuditDate(); $this->merge([ 'asset_tag' => $this->asset_tag ?? Asset::autoincrement_asset(), @@ -64,4 +52,21 @@ class StoreAssetRequest extends ImageUploadRequest return $rules; } + + private function formatLastAuditDate(): void + { + if ($this->input('last_audit_date')) { + try { + $lastAuditDate = Carbon::parse($this->input('last_audit_date')); + + $this->merge([ + 'last_audit_date' => $lastAuditDate->startOfDay()->format('Y-m-d H:i:s'), + ]); + } catch (InvalidFormatException $e) { + // we don't need to do anything here... + // we'll keep the provided date in an + // invalid format so validation picks it up later + } + } + } }