diff --git a/app/Api/V1/Requests/Models/Rule/UpdateRequest.php b/app/Api/V1/Requests/Models/Rule/UpdateRequest.php index 65e54e6354..3e476d3e41 100644 --- a/app/Api/V1/Requests/Models/Rule/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Rule/UpdateRequest.php @@ -53,6 +53,7 @@ class UpdateRequest extends FormRequest 'strict' => ['strict', 'boolean'], 'stop_processing' => ['stop_processing', 'boolean'], 'active' => ['active', 'boolean'], + 'order' => ['order', 'integer'], ]; $return = $this->getAllData($fields); @@ -150,6 +151,7 @@ class UpdateRequest extends FormRequest 'strict' => [new IsBoolean], 'stop_processing' => [new IsBoolean], 'active' => [new IsBoolean], + 'order' => 'numeric|between:1,1337', ]; } diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.php index 1990aa9af0..1c869ca6f4 100644 --- a/app/Repositories/Rule/RuleRepository.php +++ b/app/Repositories/Rule/RuleRepository.php @@ -466,6 +466,15 @@ class RuleRepository implements RuleRepositoryInterface } } $rule->save(); + $rule->refresh(); + $group = $rule->ruleGroup; + // update the order: + $this->resetRuleOrder($group); + if (array_key_exists('order', $data)) { + $this->moveRule($rule, $group, (int)$data['order']); + } + + // update the triggers: if (array_key_exists('trigger', $data) && 'update-journal' === $data['trigger']) { $this->setRuleTrigger('update-journal', $rule);