ruleGroups()->with('rules')->orderBy('order','ASC')->get(); /** @var RuleGroup $group */ foreach($groups as $group) { } } }