{{-- Variables: $permissionsByPage — Collection grouped by page key $modulePages — ['page_key' => 'Display Label'] $rolePermIds — array of permission IDs already assigned ([] for create) $readonly — bool: true = show checkmarks only, false = show checkboxes --}} @php $childPages = ['manage_inventory', 'manage_orders', 'delivery_team']; $actions = ['Create', 'Read', 'Update', 'Delete']; @endphp
{{-- ── Dashboard ─────────────────────────────────── --}} @php $page = 'dashboard'; $perms = $permissionsByPage[$page] ?? collect(); @endphp {{-- ── Product Management (parent header) ──────── --}} {{-- ── Product Management children ─────────────── --}} @foreach($childPages as $ci => $page) @php $perms = $permissionsByPage[$page] ?? collect(); $isLast = $ci === count($childPages) - 1; @endphp @endforeach {{-- ── Remaining standalone modules ────────────── --}} @foreach(['manage_content', 'manage_users', 'legal_policy'] as $page) @php $perms = $permissionsByPage[$page] ?? collect(); @endphp @endforeach
Module Permissions
{{ $modulePages[$page] }} @foreach($actions as $action) @php $perm = $perms->firstWhere('name', $action); @endphp @if($perm)
@if($readonly) {{ $action }} @else id, $rolePermIds) ? 'checked' : '' }}> @endif
@endif @endforeach
Product Management
{{ $modulePages[$page] }} @foreach($actions as $action) @php $perm = $perms->firstWhere('name', $action); @endphp @if($perm)
@if($readonly) {{ $action }} @else id, $rolePermIds) ? 'checked' : '' }}> @endif
@endif @endforeach
{{ $modulePages[$page] }} @foreach($actions as $action) @php $perm = $perms->firstWhere('name', $action); @endphp @if($perm)
@if($readonly) {{ $action }} @else id, $rolePermIds) ? 'checked' : '' }}> @endif
@endif @endforeach