Add conditional

This commit is contained in:
Marcus Moore 2024-04-25 16:24:12 -07:00
parent 1d5b48b88d
commit 30bd920497
No known key found for this signature in database

View file

@ -47,12 +47,14 @@ class StoreAssetRequest extends ImageUploadRequest
{ {
$modelRules = (new Asset)->getRules(); $modelRules = (new Asset)->getRules();
if (is_string($this->input('purchase_cost'))) {
// If purchase_cost was submitted as a string with a comma separator // If purchase_cost was submitted as a string with a comma separator
// then we need to ignore the normal numeric rules. // then we need to ignore the normal numeric rules.
// Since the original rules still live on the model they will be run // Since the original rules still live on the model they will be run
// right before saving (and after purchase_cost has been // right before saving (and after purchase_cost has been
// converted to a float via setPurchaseCostAttribute). // converted to a float via setPurchaseCostAttribute).
$modelRules = $this->removeNumericRulesFromPurchaseCost($modelRules); $modelRules = $this->removeNumericRulesFromPurchaseCost($modelRules);
}
return array_merge( return array_merge(
$modelRules, $modelRules,