@foreach($permissions as $module => $perms)
@php($moduleGrantedCount = collect($perms)->filter(fn ($p) => $role->permissions->contains('name', $p->name))->count())
@php($managePermission = collect($perms)->first(fn ($p) => $p->name === "manage-{$module}"))
@php($actionPermissions = collect($perms)->reject(fn ($p) => $p->name === "manage-{$module}"))
@php($moduleOn = $managePermission && $role->permissions->contains('name', $managePermission->name))
@include('admin.roles.partials.module-icon', ['module' => $module])
{{ ucfirst($module) }}
{{ $moduleGrantedCount }}/{{ count($perms) }}
@if($managePermission)
{{ ucfirst($module) }} access for this role
{{ $moduleOn ? 'ON' : 'OFF' }}
@endif
@if($actionPermissions->isNotEmpty())
@foreach($actionPermissions as $permission)
@php($granted = $role->permissions->contains('name', $permission->name))
@php($action = str($permission->name)->before('-')->title())
@if($granted)
@else
@endif
{{ $action }}
@endforeach
@endif
@endforeach