mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 06:04:08 -08:00
ammended note, got real rule in there
This commit is contained in:
parent
8696a423b0
commit
03f091a77f
|
@ -28,7 +28,7 @@ class UpdateAssetRequest extends ImageUploadRequest
|
||||||
$rules = array_merge(
|
$rules = array_merge(
|
||||||
parent::rules(),
|
parent::rules(),
|
||||||
(new Asset)->getRules(),
|
(new Asset)->getRules(),
|
||||||
// this is to overwrite rulesets that include required
|
// this is to overwrite rulesets that include required, and rewrite unique_undeleted
|
||||||
[
|
[
|
||||||
'model_id' => ['integer', 'exists:models,id,deleted_at,NULL', 'not_array'],
|
'model_id' => ['integer', 'exists:models,id,deleted_at,NULL', 'not_array'],
|
||||||
'status_id' => ['integer', 'exists:status_labels,id'],
|
'status_id' => ['integer', 'exists:status_labels,id'],
|
||||||
|
@ -43,12 +43,13 @@ class UpdateAssetRequest extends ImageUploadRequest
|
||||||
|
|
||||||
$rules2 = array_merge(
|
$rules2 = array_merge(
|
||||||
parent::rules(),
|
parent::rules(),
|
||||||
// collects rules, 'rejects' required rules
|
// collects rules, 'rejects' required rules not a fan of this approach, feels inflexible
|
||||||
|
// what if we decide something _is_ required, etc, it could get complicated and harder to read than the above
|
||||||
collect((new Asset)->getRules())->map(function ($rules) {
|
collect((new Asset)->getRules())->map(function ($rules) {
|
||||||
return collect($rules)->reject(function ($rule) {
|
return collect($rules)->reject(function ($rule) {
|
||||||
return $rule === 'required';
|
return $rule === 'required';
|
||||||
})->reject(function ($rule) {
|
})->reject(function ($rule) {
|
||||||
return $rule === 'unique_undeleted';
|
return $rule === 'unique_undeleted:assets,asset_tag';
|
||||||
})->values()->all();
|
})->values()->all();
|
||||||
})->all(),
|
})->all(),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue