<?php

declare(strict_types=1);

namespace App\Domain\Status\Models;

use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class StatusIncidentUpdate extends Model
{
    protected $fillable = [
        'status_incident_id',
        'status',
        'message',
        'posted_by',
        'posted_at',
    ];

    protected $casts = [
        'posted_at' => 'datetime',
    ];

    public function incident(): BelongsTo
    {
        return $this->belongsTo(StatusIncident::class, 'status_incident_id');
    }

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

    public function statusLabel(): string
    {
        return match ($this->status) {
            'investigating' => 'İnceleniyor',
            'identified' => 'Tespit Edildi',
            'monitoring' => 'İzleniyor',
            'resolved' => 'Çözüldü',
            'postmortem' => 'Olay Raporu',
            default => $this->status,
        };
    }
}
