feat: implement Dashboard for Admin PG matching reference design and fix active sidebar menu bug

This commit is contained in:
Wahyudin
2026-10-13 15:17:41 +07:00
parent 18d548df79
commit 621802c23a
7 changed files with 319 additions and 17 deletions
@@ -0,0 +1,56 @@
<?php
namespace App\Http\Controllers\Pg;
use App\Http\Controllers\Controller;
use App\Models\Gate;
use App\Models\SecurityGuard;
use App\Models\VehicleActivity;
use Carbon\Carbon;
use Illuminate\View\View;
class DashboardController extends Controller
{
/**
* Tampilkan halaman utama Dashboard Admin Private Guard (PG).
*/
public function index(): View
{
// 5 Metrik Ringkasan Utama (Persis Gaya Kartu Pastel Gambar Referensi)
$totalGuards = SecurityGuard::count();
$activeGuards = SecurityGuard::where('is_active', true)->count();
$totalGates = Gate::where('is_active', true)->count();
$todayVerifications = VehicleActivity::whereDate('recorded_at', Carbon::today())->count();
$totalRejections = VehicleActivity::where('validation_status', 'rejected')->count();
// Log Verifikasi Gerbang Terkini (Panel Kiri)
$recentActivities = VehicleActivity::with(['vehicle', 'driver', 'gate', 'securityGuard'])
->latest('recorded_at')
->take(5)
->get();
// Personel Satpam Terkini per Regu (Panel Kanan Atas)
$recentGuards = SecurityGuard::with('gate')
->orderBy('team')
->take(5)
->get();
// Ringkasan Jumlah Personel per Regu Tugas (Panel Kanan Bawah)
$team1Count = SecurityGuard::where('team', 1)->where('is_active', true)->count();
$team2Count = SecurityGuard::where('team', 2)->where('is_active', true)->count();
$team3Count = SecurityGuard::where('team', 3)->where('is_active', true)->count();
return view('pg.dashboard', compact(
'totalGuards',
'activeGuards',
'totalGates',
'todayVerifications',
'totalRejections',
'recentActivities',
'recentGuards',
'team1Count',
'team2Count',
'team3Count'
));
}
}