mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 05:47:28 -08:00
WIP: Future-proof rules being converted to array syntax
This commit is contained in:
parent
12418ae91b
commit
3a2eeaea7a
|
@ -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';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue