@php $belongsToLaw = $structure->law_id == $law->id; $repeal = $structure->repealedBy; $newLaw = $structure->newLaw; $isRepealed = $structure->repealed && $repeal; $label = $structure->structureType ? $structure->structureType->abrev . ' ' . ($structure->order_label ?? '') : ($structure->order_label ?? ''); $children = $structure->children->filter(fn($child) => $child->law_id == $law->id); $addedArticles = \App\Models\Structure::where(function($query) use ($structure, $law) { $query->where('structure_id', $structure->id) ->orWhere('parent_id', $structure->id); }) ->where('law_id', $law->id) ->orderBy('order') ->get(); $allChildren = $children->merge($addedArticles)->unique('id')->sortBy('order'); @endphp @if($belongsToLaw)