WIP: Future-proof rules being converted to array syntax

This commit is contained in:
Marcus Moore 2024-04-24 17:40:40 -07:00
parent 12418ae91b
commit 3a2eeaea7a
No known key found for this signature in database

View file

@ -47,9 +47,7 @@ class StoreAssetRequest extends ImageUploadRequest
{
$modelRules = (new Asset)->getRules();
$modelRules['purchase_cost'] = array_filter(explode('|', $modelRules['purchase_cost']), function ($rule) {
return $rule !== 'numeric' && $rule !== 'gte:0';
});
$modelRules['purchase_cost'] = $this->removeNumericRulesFromPurchaseCost($modelRules['purchase_cost']);
$rules = array_merge(
$modelRules,
@ -75,4 +73,16 @@ class StoreAssetRequest extends ImageUploadRequest
}
}
}
private function removeNumericRulesFromPurchaseCost($purchaseCost)
{
// If rule is in "|" format then turn it into an array
if (is_string($purchaseCost)) {
$purchaseCost = explode('|', $purchaseCost);
}
return array_filter($purchaseCost, function ($rule) {
return $rule !== 'numeric' && $rule !== 'gte:0';
});
}
}