From 71722b753d87e056e366450604dda21c7b8e189c Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Mon, 25 Mar 2024 13:49:03 -0700 Subject: [PATCH] Little bit of clean up --- app/Http/Requests/StoreAssetRequest.php | 31 ++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) 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 + } + } + } }