<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Incident extends Model
{
    use HasFactory;

    public $timestamps = false;

    protected $fillable = [
        'name',
        'impact',
        'components',
        'status',
        'show_status',
        'server_name'
    ];

    protected $casts = [
        'components' => 'array'
    ];

    public function CurrentIncidentMessage(){
        return $this->hasOne(IncidentMessage::class)->orderBy('id' , 'DESC');
    }

    public function incident_message(){
        return $this->hasMany(IncidentMessage::class);
    }
}
