<?php

namespace App\Modules\Pilkades\Http\Controllers\SuperAdmin;

use App\Http\Controllers\Controller;
use App\Modules\Pilkades\Models\AuditLog;
use Illuminate\Http\Request;
use Illuminate\View\View;

class AuditLogController extends Controller
{
    public function index(Request $request): View
    {
        $logs = AuditLog::with('user', 'desa')
            ->when($request->filled('desa_id'), fn ($q) => $q->where('desa_id', $request->string('desa_id')))
            ->latest('created_at')
            ->paginate(30);

        return view('pilkades::super-admin.audit-log.index', compact('logs'));
    }
}
