48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Modules\Itsecurity\Models\Master\JenisForm;
|
|
use Modules\Itsecurity\Models\Pengajuan\Permohonan;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$formCounts = JenisForm::withCount('permohonan')
|
|
->get()
|
|
->map(function ($jenisForm) {
|
|
return [
|
|
'kode_form' => $jenisForm->kode_form,
|
|
'nama_form' => $jenisForm->nama_form,
|
|
'total' => $jenisForm->permohonan_count,
|
|
];
|
|
});
|
|
|
|
return view('welcome', compact('formCounts'));
|
|
}
|
|
|
|
// public function headerNotification()
|
|
// {
|
|
// $user = Auth::user();
|
|
|
|
// // Ambil permohonan terbaru oleh user yang login
|
|
// $permohonanTerbaru = Permohonan::with('jenisForm')
|
|
// ->where('nik', $user->nik)
|
|
// ->whereDate('created_at', now()->toDateString()) // Hanya hari ini
|
|
// ->latest()
|
|
// ->first();
|
|
|
|
// $notification = null;
|
|
|
|
// if ($permohonanTerbaru && $permohonanTerbaru->jenisForm?->kode_form === 'S1000') {
|
|
// $tanggal = \Carbon\Carbon::parse($permohonanTerbaru->created_at)->format('d M Y');
|
|
// $notification = "Kamu baru saja membuat permohonan firewall pada tanggal $tanggal.";
|
|
// }
|
|
|
|
// return view('dashboard.index', compact('notification'));
|
|
// }
|
|
}
|