<?php

namespace App\Services;

use App\Models\EarnAudit;
use App\Models\EarnMember;
use Illuminate\Http\Request;

class EarnAuditLogger
{
    public function record(string $event, ?EarnMember $member, Request $request, array $metadata = []): void
    {
        EarnAudit::query()->create([
            'earn_member_id' => $member?->id,
            'event' => $event,
            'ip_address' => $request->ip(),
            'metadata' => $metadata ?: null,
            'created_at' => now(),
        ]);
    }
}
