<?php
declare(strict_types=1);
namespace App\Repositories;
use App\Core\Repository;

final class AuditRepository extends Repository {
    public function recent(string $module=''): array {
        $where = '';
        $params = [];
        if ($module !== '') {
            $where = " WHERE module_name = ? ";
            $params[] = $module;
        }
        return $this->all("SELECT al.*, u.full_name user_name
            FROM audit_logs al
            LEFT JOIN users u ON u.id = al.user_id
            $where
            ORDER BY al.id DESC LIMIT 300", $params);
    }
}
