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