@foreach ($sidebar as $section) @php $items = collect($section['items'])->filter(function ($item) { return !isset($item['can']) || auth()->user()?->can($item['can']); }); @endphp @if ($items->isNotEmpty()) @if ($section['heading'])
{{ $section['heading'] }}
@foreach ($items as $item) {{ $item['label'] }} @endforeach
@else @foreach ($items as $item) {{ $item['label'] }} @endforeach @endif @endif @endforeach