{{-- Access — the role decides everything this person may do in the portal. --}} @php use App\Support\Permissions; $actor = auth()->user(); $self = $user->is($actor); $canRoles = $actor->canAccess(Permissions::ROLES); $role = $user->primaryRole(); $effective = $user->effectivePermissions(); $screens = array_values(array_intersect(Permissions::pageNames(), $effective)); $admin = array_values(array_intersect( [Permissions::USERS, Permissions::ROLES, Permissions::VERSIONS, Permissions::DIGEST, Permissions::QUICK_LOGIN], $effective, )); $scope = in_array(Permissions::VIEW_ALL, $effective, true) ? 'Everyone in the company' : (in_array(Permissions::VIEW_TEAM, $effective, true) ? 'Members of the teams they lead, and themselves' : 'Only themselves'); // Why the role can't be changed from here, if it can't. $locked = match (true) { $user->isSuperAdmin() => 'The Super Admin has every permission, whatever the role.', $user->roleFromWorkspace() => 'Follows their workspace role (“' . $user->workspace_role . '”) — change it in the workspace.', $self => 'You can’t change your own role.', ! $canRoles => 'Assigning roles needs Manage Roles & Permissions.', default => null, }; @endphp

Access

Their role decides what they can open and whose data they see
@csrf @method('PATCH')
@if ($locked) {{-- No name: the save then leaves the role as it is. --}}
{{ $locked }}
@else
Only roles holding no more than your own access are offered.
@endif @if ($role && $canRoles) What “{{ $role->label ?? $role->name }}” can do → @endif

Sign-in link

Personal link @if ($loginLink) Active sent {{ $loginLink->created_at->diffForHumans() }} · {{ $loginLink->used_at ? 'last used ' . $loginLink->used_at->diffForHumans() . ($loginLink->used_ip ? ' from ' . $loginLink->used_ip : '') : 'not used yet' }} @else None Send Portal Invite gives them one @endif @if ($loginLink)
@csrf
@endif

Effective access

Screens @if ($screens) {{ collect($screens)->map(fn ($p) => Permissions::label($p))->implode(', ') }} @else None — desktop only @endif
Whose data {{ $screens ? $scope : '—' }} @if ($screens && $activity['visible_count'] !== null) {{ $activity['visible_count'] }} {{ \Illuminate\Support\Str::plural('person', $activity['visible_count']) }} today @endif
Administration {{ $admin ? collect($admin)->map(fn ($p) => Permissions::label($p))->implode(', ') : '—' }}
From {{ $user->isSuperAdmin() ? 'Super Admin' : ($role ? ($role->label ?? $role->name) . ' role' : 'No role') }} @if ($user->status === \App\Support\EmployeeStatus::INACTIVE) inactive — no access while they are @endif