{{-- 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