<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Approval extends Model
{
    protected $casts = [
        'metadata' => 'array',
        'step' => ApprovalStep::class
    ];
    
    public function transitionTo($status, $comment = null)
    {
        $this->update([
            'status' => $status,
            'comment' => $comment,
            'completed_at' => now()
        ]);
        
        $this->document->notifyApprovers();
    }
}
