<?php
namespace Bot\Services;

use Bot\Database;
use PDO;

class AdminActivityService
{
    private PDO $pdo;

    public function __construct()
    {
        $this->pdo = Database::connection();
    }

    public function log(int $adminId, string $action, ?int $targetUserId = null, array $meta = []): void
    {
        $stmt = $this->pdo->prepare(
            "INSERT INTO admin_activity (admin_id, action, target_user_id, meta, created_at)
             VALUES (:admin, :action, :target, :meta, NOW())"
        );
        $stmt->execute([
            ':admin'  => $adminId,
            ':action' => $action,
            ':target' => $targetUserId,
            ':meta'   => $meta ? json_encode($meta, JSON_THROW_ON_ERROR) : null,
        ]);
    }
}
