<?php

namespace App\Http\Controllers;

use App\Models\BukuTamu;
use App\Models\Peminjaman;
use Illuminate\Http\Request;

class LaporanController extends Controller
{
    public function kehadiran()
    {
        $bukuTamu = BukuTamu::with('user')
            ->orderBy('tanggal_kunjungan', 'desc')
            ->get();

        return view('laporan.kehadiran', compact('bukuTamu'));
    }

    public function peminjaman(Request $request)
    {
        $query = Peminjaman::with(['anggota', 'user', 'buku'])->orderBy('tanggal_pinjam', 'desc');
        
        // Optional filtering by month/year if needed (can be added later)
        
        $peminjaman = $query->get();

        return view('laporan.peminjaman', compact('peminjaman'));
    }
}
