29 lines
810 B
PHP
29 lines
810 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Anggota;
|
|
use App\Models\Buku;
|
|
use App\Models\Peminjaman;
|
|
use App\Models\Kategori;
|
|
use Inertia\Inertia;
|
|
|
|
class DashboardController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
return Inertia::render('Dashboard', [
|
|
'stats' => [
|
|
'total_buku' => Buku::count(),
|
|
'total_anggota' => Anggota::where('status', 'aktif')->count(),
|
|
'total_peminjaman' => Peminjaman::where('status', 'dipinjam')->count(),
|
|
'total_terlambat' => Peminjaman::where('status', 'terlambat')->count(),
|
|
],
|
|
'peminjaman_terbaru' => Peminjaman::with(['anggota', 'buku'])
|
|
->latest()
|
|
->take(5)
|
|
->get(),
|
|
]);
|
|
}
|
|
}
|