<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ApprovalWorkflow extends Model
{
    protected $casts = ['steps' => 'array'];
    
    public function getCurrentStep(Document $document)
    {
        $lastApproval = $document->approvals()->latest()->first();
        return $lastApproval ? $this->steps[$lastApproval->step_index + 1] : $this->steps[0];
    }
}
