{{-- Permission matrix partial — tree view with collapsible tabs. Variables: $groupedPermissions — tree from RoleManagementController::groupPermissions() $idPrefix — 'add' | 'edit' $rolePermIds — array of pre-selected permission IDs (empty for add) --}} @foreach ($groupedPermissions as $category => $perms) @php $catSlug = Str::slug($category); $allInCat = collect($perms)->flatMap(function ($m) { $ids = []; if ($m['manage']) $ids[] = $m['manage']->id; if ($m['view']) $ids[] = $m['view']->id; foreach ($m['tabs'] as $t) { if ($t['manage']) $ids[] = $t['manage']->id; if ($t['view']) $ids[] = $t['view']->id; } return $ids; })->values(); $totalInCat = $allInCat->count(); @endphp
{{-- ── Category header ── --}}
{{ $category }} 0 / {{ $totalInCat }}
{{-- ── Column headers ── --}}
{{ __('Manage') }}
{{ __('View') }}
@foreach ($perms as $menuName => $menuData) @php $hasTabs = ! empty($menuData['tabs']); $menuSlug = Str::slug($menuName); $collapseId = $idPrefix . '-tabs-' . $catSlug . '-' . $menuSlug; $tabCount = count($menuData['tabs']); @endphp
{{-- ── Menu-level row ── --}}
{{-- Manage column --}}
@if($menuData['manage']) @php $p = $menuData['manage']; @endphp
@if($hasTabs) @else @endif
id, $rolePermIds ?? [])) checked @endif>
@endif
{{-- View column --}}
@if($menuData['view']) @php $p = $menuData['view']; @endphp
id, $rolePermIds ?? [])) checked @endif>
@endif
{{-- ── Collapsible tab rows ── --}} @if($hasTabs)
{{ __('Manage Tab') }}
{{ __('View Tab') }}
@foreach ($menuData['tabs'] as $tabSlug => $tabPerms)
{{-- Manage tab --}}
@if($tabPerms['manage']) @php $p = $tabPerms['manage']; @endphp
id, $rolePermIds ?? [])) checked @endif>
@endif
{{-- View tab --}}
@if($tabPerms['view']) @php $p = $tabPerms['view']; @endphp
id, $rolePermIds ?? [])) checked @endif>
@endif
@endforeach
@endif
@endforeach
@endforeach