From 30bd92049724685999b1b1975c1d76a04de7733f Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 25 Apr 2024 16:24:12 -0700 Subject: [PATCH] Add conditional --- app/Http/Requests/StoreAssetRequest.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Http/Requests/StoreAssetRequest.php b/app/Http/Requests/StoreAssetRequest.php index fb23ac8f2f..bbf3a98442 100644 --- a/app/Http/Requests/StoreAssetRequest.php +++ b/app/Http/Requests/StoreAssetRequest.php @@ -47,12 +47,14 @@ class StoreAssetRequest extends ImageUploadRequest { $modelRules = (new Asset)->getRules(); - // If purchase_cost was submitted as a string with a comma separator - // then we need to ignore the normal numeric rules. - // Since the original rules still live on the model they will be run - // right before saving (and after purchase_cost has been - // converted to a float via setPurchaseCostAttribute). - $modelRules = $this->removeNumericRulesFromPurchaseCost($modelRules); + if (is_string($this->input('purchase_cost'))) { + // If purchase_cost was submitted as a string with a comma separator + // then we need to ignore the normal numeric rules. + // Since the original rules still live on the model they will be run + // right before saving (and after purchase_cost has been + // converted to a float via setPurchaseCostAttribute). + $modelRules = $this->removeNumericRulesFromPurchaseCost($modelRules); + } return array_merge( $modelRules,