<?php

namespace App\Models\Office;

use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ApprovalNode extends Model
{
    const UPDATED_AT = null;

    protected $fillable = [
        'approval_id', 'node_order', 'node_label', 'role',
        'approver_id', 'action', 'comment', 'acted_at',
    ];

    protected function casts(): array
    {
        return [
            'node_order' => 'integer',
            'action' => 'integer',
            'acted_at' => 'datetime',
        ];
    }

    public function approval(): BelongsTo
    {
        return $this->belongsTo(Approval::class);
    }

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