@extends('layouts.app') @section('title', 'User Details') @section('page-title', 'User Details') @section('content') View user account information, assigned role, and system access permissions. {{-- Page Actions --}}
@can('users.edit') Edit User @endcan Back
@php $role = $user->roles->first(); $roleClasses = match ($role?->name) { 'Super Admin' => 'bg-purple-50 text-purple-700', 'Admin' => 'bg-sky-50 text-sky-700', 'Teacher' => 'bg-emerald-50 text-emerald-700', 'Parent' => 'bg-amber-50 text-amber-700', 'Student' => 'bg-indigo-50 text-indigo-700', default => 'bg-background text-muted', }; /* |-------------------------------------------------------------------------- | Effective Permissions |-------------------------------------------------------------------------- | | getAllPermissions() includes permissions inherited through roles | as well as any direct permissions assigned to the user. | */ $permissions = $user ->getAllPermissions() ->sortBy('name') ->values(); /* |-------------------------------------------------------------------------- | Group Permissions |-------------------------------------------------------------------------- | | Example: | | students.view | students.create | | becomes: | | students | view | create | */ $groupedPermissions = $permissions->groupBy( function ($permission) { return explode( '.', $permission->name, 2 )[0]; } ); @endphp {{-- User Information --}}
{{-- Header --}}
{{-- Avatar --}}
{{ mb_substr($user->name, 0, 1) }}

{{ $user->name }}

@if (auth()->id() === $user->id) You @endif

{{ $user->email }}

{{-- Role --}} @if ($role) {{ $role->name }} @else No Role @endif {{-- Status --}} @if ($user->is_active) Active @else Inactive @endif
{{-- Main Details --}}
{{-- Name --}}

Full Name

{{ $user->name }}

{{-- Email --}}

Email Address

{{ $user->email }}

{{-- Role --}}

Assigned Role

@if ($role) {{ $role->name }} @else No role assigned @endif
{{-- Status --}}

Account Status

@if ($user->is_active) Active @else Inactive @endif
{{-- Secondary Details --}}
{{-- Email Verification --}}

Email Verification

@if ($user->email_verified_at) Verified @else Not Verified @endif
{{-- Verified At --}}

Verified At

{{ $user->email_verified_at ? $user->email_verified_at->format('d M Y, h:i A') : '—' }}

{{-- Created --}}

Created At

{{ $user->created_at?->format('d M Y, h:i A') ?? '—' }}

{{-- Updated --}}

Last Updated

{{ $user->updated_at?->format('d M Y, h:i A') ?? '—' }}

{{-- Access Summary --}}
{{-- Roles --}}

Assigned Roles

{{ $user->roles->count() }}

{{-- Effective Permissions --}}

Effective Permissions

{{ $permissions->count() }}

{{-- Account --}}

Account

{{ $user->is_active ? 'Active' : 'Inactive' }}

{{-- Assigned Role --}}
{{-- Header --}}

Assigned Role

The role assigned to this user controls their system access.

@if ($role)

{{ $role->name }}

{{ $role->permissions->count() }} {{ Str::plural( 'permission', $role->permissions->count() ) }} assigned

@can('roles.view') View Role @endcan
@else

No Role Assigned

This user currently has no system role assigned.

@endif
{{-- Effective Permissions --}}
{{-- Header --}}

Effective Permissions

Permissions currently available to this user through their assigned role.

{{ $permissions->count() }} {{ Str::plural( 'Permission', $permissions->count() ) }}
@if ($groupedPermissions->isNotEmpty())
@foreach ($groupedPermissions as $module => $modulePermissions)
{{-- Module --}}

{{ Str::headline($module) }}

{{ $modulePermissions->count() }} {{ Str::plural( 'permission', $modulePermissions->count() ) }}

{{-- Permissions --}}
@foreach ($modulePermissions as $permission) @php $parts = explode( '.', $permission->name, 2 ); $action = $parts[1] ?? $permission->name; $permissionClasses = match ($action) { 'view' => 'bg-sky-50 text-sky-700', 'create' => 'bg-emerald-50 text-emerald-700', 'edit' => 'bg-amber-50 text-amber-700', 'delete' => 'bg-red-50 text-red-700', default => 'bg-background text-muted', }; @endphp
{{ $permission->name }} {{ Str::headline($action) }}
@endforeach
@endforeach
@else {{-- Empty Permissions --}}

No Permissions Available

This user does not currently have any effective system permissions. Assign an appropriate role to provide system access.

@endif
{{-- Security Information --}}

Role-Based Access Control

This user's effective permissions are determined by the assigned role. Permission changes should normally be managed through Role Management so access remains consistent between users with the same responsibilities.

{{-- Super Admin Warning --}} @if ($user->hasRole('Super Admin'))

Super Admin Account

This account has the highest administrative role. Changes to its role, status, or account access should be made carefully.

@endif {{-- Bottom Actions --}}
Back to Users @can('users.edit') Edit User @endcan
@endsection