<?php

namespace App\Modules\Operations\Models;

use App\Models\User;
use App\Modules\Admin\Tenancy\Traits\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class OperationalControlEvent extends Model
{
    use BelongsToTenant;

    protected $table = 'operational_control_events';

    protected $fillable = [
        'tenant_id',
        'channel',
        'category',
        'severity',
        'event_code',
        'summary',
        'correlation_id',
        'reference_type',
        'reference_id',
        'meta',
        'acknowledged_at',
        'acknowledged_by',
    ];

    protected function casts(): array
    {
        return [
            'meta' => 'array',
            'acknowledged_at' => 'datetime',
        ];
    }

    public function acknowledgedByUser(): BelongsTo
    {
        return $this->belongsTo(User::class, 'acknowledged_by');
    }
}
