<?php
namespace App\Controllers\Admin;

use Core\View;
use App\Models\AuditLog;

class AuditController
{
    public function index()
    {
        // Fetch raw system changes tracked natively by Coreflux framework
        $sql = "
            SELECT a.*, u.full_name, u.role 
            FROM audit_logs a
            LEFT JOIN users u ON a.changed_by = u.id
            ORDER BY a.created_at DESC
            LIMIT 100
        ";
        
        View::make('admin/audit_logs')
            ->setLayout('admin_layout')
            ->with([
                'title' => 'System Audit Logs',
                'logs' => AuditLog::fetchAll($sql)
            ])->render();
    }
}