Add controllers for Anggota, Buku, Kategori, Peminjaman, and Dashboard with CRUD operations
This commit is contained in:
28
app/Http/Controllers/DashboardController.php
Normal file
28
app/Http/Controllers/DashboardController.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user