@php use App\Support\PermissionCatalog; $r = $role ?? null; $selected = old('permissions', $r ? $r->permissions->pluck('name')->all() : []); $byName = $permissions->keyBy('name'); $groups = PermissionCatalog::groups(); @endphp
@foreach ($groups as $groupKey => $names) @php $items = collect($names)->filter(fn ($n) => $byName->has($n)); @endphp @continue($items->isEmpty())

{{ PermissionCatalog::groupLabel($groupKey) }}

@foreach ($items as $name) @endforeach
@endforeach