<?php

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

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

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

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