<?php

namespace Modules\Vrc\Entities;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class VrcNcr extends Model
{
    protected $table = 'vrc_ncrs';

    protected $fillable = [
        'business_id', 'number', 'source', 'title', 'description', 'severity', 'status',
        'repair_order_id', 'ticket_id', 'raised_by', 'raised_at', 'closed_at',
    ];

    protected $casts = [
        'raised_at' => 'datetime',
        'closed_at' => 'datetime',
    ];

    public const STATUSES = ['open', 'investigating', 'action_planned', 'closed'];

    public function capas(): HasMany
    {
        return $this->hasMany(VrcCapa::class, 'ncr_id');
    }
}
