<?php

namespace App\Models;

use App\Traits\Blameable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ClaimHistory extends Model
{
    use HasFactory, Blameable;

    public $fillable = [
        'claim_id',
        'title',
        'description',
        'type',
        'parent_id',
        'data',
        'system_origin'
    ];

    public static $types = [
        'info',
        'document-request',
        'document-submit'
    ];

    public function parent()
    {
        return $this->belongsTo(ClaimHistory::class, 'parent_id');
    }

    public function childs()
    {
        return $this->hasMany(Claimhistory::class, 'parent_id');
    }

    public function claim()
    {
        return $this->belongsTo(Claim::class, 'claim_id');
    }

    public function historiable()
    {
        return $this->morphTo();
    }
}
