@extends('layouts.admin') @section('title', 'User Management — Admin DaisyRisk') @section('page-title', 'User Management') @section('content') {{-- ══════════════════════════════════════════════════════════════ USER STATISTICS CARDS ══════════════════════════════════════════════════════════════ --}}
{{ \App\Models\User::count() }}
Total Users
Semua pengguna terdaftar
{{ \App\Models\User::where('status', 'active')->count() }}
Active Users
Pengguna aktif
{{ \App\Models\User::where('status', 'inactive')->count() }}
Inactive Users
Pengguna tidak aktif
{{ \App\Models\User::whereMonth('created_at', now()->month)->whereYear('created_at', now()->year)->count() }}
New This Month
Pengguna baru bulan ini
{{-- ══════════════════════════════════════════════════════════════ SEARCH & FILTER SECTION ══════════════════════════════════════════════════════════════ --}}
🔍 Cari & Filter User
Reset
{{-- ══════════════════════════════════════════════════════════════ ACTION BUTTONS ══════════════════════════════════════════════════════════════ --}}

👥 Daftar User ({{ $users->total() }})

Kelola data pengguna sistem

Export CSV
{{-- ══════════════════════════════════════════════════════════════ USERS TABLE ══════════════════════════════════════════════════════════════ --}}
@if($users->count() > 0)
@foreach($users as $user) @endforeach
User Role Company Status Joined Actions
@if($user->profile_photo) Avatar @elseif(($user->role->role_name ?? null) === 'Admin' || ($user->role->role_name ?? null) === 'Super Admin') @else
{{ strtoupper(substr($user->name, 0, 1)) }}
@endif
{{ $user->name }}
{{ $user->email }}
{{ $user->role->name ?? 'No Role' }} {{ $user->company_name ?: '-' }} @if($user->status === 'active') Aktif @else Tidak Aktif @endif
{{ $user->created_at->format('M d, Y') }}
{{ $user->created_at->diffForHumans() }}
{{-- View Button --}} {{-- Edit Button --}} {{-- Toggle Status Button --}} @if($user->id !== auth()->id())
@csrf @method('PATCH')
@endif {{-- Delete Button - Tidak bisa hapus diri sendiri & Admin terakhir --}} @php $isCurrentUser = $user->id === auth()->id(); $isLastAdmin = ($user->role && $user->role->name === 'Administrator' && \App\Models\User::whereHas('role', function($q) { $q->where('role_name', 'Administrator'); })->count() <= 1); @endphp @if(!$isCurrentUser && !$isLastAdmin)
@csrf @method('DELETE')
@elseif($isCurrentUser) @elseif($isLastAdmin) @endif
@else {{-- Empty State --}}
Tidak ada user ditemukan
@endif
{{-- ══════════════════════════════════════════════════════════════ PAGINATION ══════════════════════════════════════════════════════════════ --}} @if($users->hasPages())
@endif @endsection @push('styles') @endpush @push('scripts') @endpush