<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;

class IspIncident extends Model
{
    protected $fillable = ['isp_id','client_id','down_at','up_at','description','status'];
    protected $casts    = ['down_at'=>'datetime','up_at'=>'datetime'];

    public function isp()    { return $this->belongsTo(Isp::class); }
    public function client() { return $this->belongsTo(Client::class); }
    public function getDurationAttribute(): string
    {
        if (!$this->up_at) return 'Ongoing';
        return $this->down_at->diffForHumans($this->up_at, true);
    }
}
