<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Str;

class SecurityEventLog extends Model
{
    protected $fillable = [
        'uuid',
        'event_type',
        'severity',
        'user_id',
        'user_email',
        'ip_address',
        'user_agent',
        'method',
        'url',
        'route_name',
        'session_id_hash',
        'request_id',
        'subject_type',
        'subject_id',
        'metadata',
        'detected_value_hash',
        'detected_value_preview',
        'status',
    ];

    protected static function booted()
    {
        static::creating(function ($model) {
            if (empty($model->uuid)) {
                $model->uuid = (string) Str::uuid();
            }
        });
    }
}
