<?php

namespace App\Models;

use App\Services\AuditLogger;
use Illuminate\Database\Eloquent\Model;

/** 运维/后台动作留痕表 audit_logs（写入请走 {@see AuditLogger}）。 */
final class AuditLog extends Model
{
    public const UPDATED_AT = null;

    protected $table = 'audit_logs';

    /** @var list<string> */
    protected $fillable = [
        'operator_type',
        'operator_id',
        'module_code',
        'action_code',
        'target_type',
        'target_id',
        'before_json',
        'after_json',
        'ip',
        'user_agent',
    ];

    protected function casts(): array
    {
        return [
            'operator_id' => 'integer',
            'before_json' => 'json',
            'after_json' => 'json',
            'created_at' => 'datetime',
        ];
    }
}
