<?php
/**
 * ActivityLog Model
 * Maps to `activity_logs` table
 */

require_once __DIR__ . '/../Core/Model.php';
require_once __DIR__ . '/../Helpers/Security.php';

class ActivityLog extends Model {
    protected string $table = 'activity_logs';

    public function record(?int $userId, string $action, ?string $entityType = null, ?int $entityId = null, ?string $description = null): void {
        $this->insert([
            'user_id' => $userId,
            'action' => $action,
            'entity_type' => $entityType,
            'entity_id' => $entityId,
            'description' => $description,
            'ip_address' => Security::getClientIp(),
            'created_at' => date('Y-m-d H:i:s')
        ]);
    }
}
