<?php

declare(strict_types=1);

namespace ImovelZapAi\SuperAdmin\Infrastructure\Persistence\Eloquent;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use ImovelZapAi\Shared\Infrastructure\Persistence\Concerns\HasUuidPrimaryKey;

class PlatformAuditLogModel extends Model
{
    use HasUuidPrimaryKey;

    protected $table = 'platform_audit_logs';

    /** @var list<string> */
    protected $fillable = [
        'operator_id',
        'action',
        'subject_type',
        'subject_id',
        'tenant_id',
        'payload',
        'ip_address',
        'user_agent',
    ];

    /** @return array<string, string> */
    protected function casts(): array
    {
        return [
            'payload' => 'array',
        ];
    }

    public function operator(): BelongsTo
    {
        return $this->belongsTo(PlatformOperatorModel::class, 'operator_id');
    }
}
