@props(['comment', 'level' => 0]) @php // Check if this comment or any of its descendants are not deleted $hasNonDeletedDescendants = false; if ($comment->deleted_at === null) { $hasNonDeletedDescendants = true; } else { // Check if any children are not deleted foreach ($comment->children as $child) { if ($child->deleted_at === null) { $hasNonDeletedDescendants = true; break; } // Recursively check grandchildren if (count($child->children) > 0) { foreach ($child->children as $grandchild) { if ($grandchild->deleted_at === null) { $hasNonDeletedDescendants = true; break 2; } } } } } @endphp @if($hasNonDeletedDescendants)