<?php

class AuditLogController extends Controller
{
    public function index(): void
    {
        Auth::requirePermission('audit_log', 'view');
        $db = Database::getConnection();
        $logs = $db->query(
            "SELECT al.*, u.full_name FROM audit_log al
             LEFT JOIN users u ON u.id = al.user_id
             ORDER BY al.id DESC LIMIT 200"
        )->fetchAll();

        $this->view('admin.audit-log.index', [
            'pageTitle' => 'Audit Log',
            'logs'      => $logs,
        ]);
    }
}
