ruleGroups()->where('rule_groups.active', 1)->orderBy('order', 'ASC')->get(); // /** @var RuleGroup $group */ foreach ($groups as $group) { $rules = $group->rules() ->leftJoin('rule_triggers', 'rules.id', '=', 'rule_triggers.rule_id') ->where('rule_triggers.trigger_type', 'user_action') ->where('rule_triggers.trigger_value', 'store-journal') ->where('rules.active', 1) ->get(['rules.*']); /** @var Rule $rule */ foreach ($rules as $rule) { $processor = Processor::make($rule); $processor->handleTransactionJournal($event->journal); if ($rule->stop_processing) { return true; } } } return true; } }