<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class SopInteractiveTask extends Model
{
    /**
     * 可批量赋值的属性
     *
     * @var array<string>
     */
    protected $fillable = [
        'sop_step_id',
        'task_type',
        'task_config',
        'validation_rules',
        'timeout_seconds',
        'is_required',
    ];

    /**
     * 属性类型转换
     *
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'task_config' => 'array',
            'validation_rules' => 'array',
            'is_required' => 'boolean',
        ];
    }

    /**
     * 获取任务所属的步骤
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function step()
    {
        return $this->belongsTo(SopStep::class, 'sop_step_id');
    }
}
