<?php

namespace Modules\Approval\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Modules\Approval\Models\Traits\HasApprovalWorkflow;
use Modules\Auth\Models\Role;

class ApprovalWorkflowStep extends Model
{
    use HasApprovalWorkflow;

    protected $fillable = [
        'approval_workflow_id',
        'role_id',
        'level',
        'name',
        'permission_name',
        'is_required',
    ];

    public $timestamps = false;
    
    protected $casts = [
        'is_required' => 'boolean',
    ];

    public function role(): BelongsTo
    {
        return $this->belongsTo(Role::class, 'role_id');
    }

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