<?php

namespace App\Services;

use App\Models\AuditLog;
use Illuminate\Support\Facades\Auth;

class AuditLogService
{
    public function log(string $action, $entity = null, array $oldValues = null, array $newValues = null)
    {
        return \App\Models\AuditLog::create([
            'user_id' => Auth::id(),
            'action' => $action,
            'entity_type' => $entity ? get_class($entity) : null,
            'entity_id' => $entity ? $entity->id : null,
            'old_values' => $oldValues,
            'new_values' => $newValues,
        ]);
    }
}
