<?php
namespace Peak;

class Activity {
    public static function handleRequest(string $method): void {
        Auth::requireAuth();
        if ($method === 'GET') {
            Response::json(Database::fetchAll('SELECT action, details FROM activity_log ORDER BY created_at DESC'));
        }
        if ($method === 'POST') {
            $data = Request::json();
            Database::query('INSERT INTO activity_log (action, details) VALUES (?, ?)', [$data['action'], $data['details'] ?? null]);
            Response::json(['success' => true]);
        }
        Response::error('Not found', 404);
    }
}
