@php $school = auth()->user()->school; $tabRoles = $school?->penggunaRoles() ?? []; $studentCount = $school ? $school->students()->count() : 0; $roleCounts = \App\Models\User::query() ->when($school, fn ($q) => $q->where('school_id', $school->id)) ->whereIn('role', $tabRoles) ->selectRaw('role, COUNT(*) AS total') ->groupBy('role') ->pluck('total', 'role') ->all(); $tabHrefs = []; foreach ($tabRoles as $key) { $tabHrefs[$key] = match ($key) { 'guru' => route('admin.guru.index'), 'staff' => route('admin.staff.index'), default => route('admin.pengguna.index', ['role' => $key]), }; } @endphp
@forelse ($tabHrefs as $key => $href) {{ $school->roleLabel($key) }} ({{ $roleCounts[$key] ?? 0 }}) @empty

Tidak ada role yang aktif. Aktifkan di Pengaturan Sekolah.

@endforelse Siswa ({{ $studentCount }})