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 purchase_cost was submitted as a string with a comma separator if (is_string($this->input('purchase_cost'))) {
// then we need to ignore the normal numeric rules. // If purchase_cost was submitted as a string with a comma separator
// Since the original rules still live on the model they will be run // then we need to ignore the normal numeric rules.
// right before saving (and after purchase_cost has been // Since the original rules still live on the model they will be run
// converted to a float via setPurchaseCostAttribute). // right before saving (and after purchase_cost has been
$modelRules = $this->removeNumericRulesFromPurchaseCost($modelRules); // converted to a float via setPurchaseCostAttribute).
$modelRules = $this->removeNumericRulesFromPurchaseCost($modelRules);
}
return array_merge( return array_merge(
$modelRules, $modelRules,