<?php

namespace App\Domain\Website\Models;

use App\Domain\Identity\Models\User;
use App\Domain\Website\Enums\RequisitionStatus;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class EmployerRequisitionStatusHistory extends Model
{
    protected $guarded = ['id'];

    protected function casts(): array
    {
        return [
            'from_status' => RequisitionStatus::class,
            'to_status' => RequisitionStatus::class,
            'changed_at' => 'datetime',
        ];
    }

    public function requisition(): BelongsTo
    {
        return $this->belongsTo(EmployerRequisition::class, 'employer_requisition_id');
    }

    public function changedBy(): BelongsTo
    {
        return $this->belongsTo(User::class, 'changed_by');
    }
}
