<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

class BugHistory extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = ['bug_id','actor_id','action','from_status','to_status','comment','metadata'];

    protected function casts(): array
    {
        return ['metadata' => 'array'];
    }

    public function bug(): BelongsTo { return $this->belongsTo(Bug::class); }
    public function actor(): BelongsTo { return $this->belongsTo(User::class, 'actor_id'); }
}
