<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\Pasien;
use App\Models\Diagnosa;
use App\Models\Penyakit;
use App\Models\Gejala;

class DashboardController extends Controller
{
    public function index()
    {
        // STATISTIK
        $totalPasien   = Pasien::count();
        $totalDiagnosa = Diagnosa::count();
        $totalPenyakit = Penyakit::count();
        $totalGejala   = Gejala::count();

        // DATA CHART
        $chart = Diagnosa::selectRaw('penyakit_id, COUNT(*) as total')
            ->groupBy('penyakit_id')
            ->with('penyakit')
            ->get();

        return view('admin.dashboard', compact(
            'totalPasien',
            'totalDiagnosa',
            'totalPenyakit',
            'totalGejala',
            'chart'
        ));
    }
}