<?php

namespace Modules\Approval\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Modules\Core\Traits\HasStatus;

class ApprovalWorkflow extends Model
{
    use HasStatus;

    protected $fillable = [
        'code',
        'name',
        'status',
    ];

    public $timestamps = false;

    public const PURCHASE_REQUISITION = 'PURCHASE_REQUISITION';
    public const PURCHASE_INVOICE = 'PURCHASE_INVOICE';
    public const PURCHASE_PAYMENT = 'PURCHASE_PAYMENT';

    public function steps(): HasMany
    {
        return $this->hasMany(ApprovalWorkflowStep::class)->orderBy('level');
    }

    public function approvalRequests(): HasMany
    {
        return $this->hasMany(ApprovalRequest::class);
    }
}
