<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class EmployeeProcessTask extends Model
{
    use HasFactory;

    protected $fillable = [
        'employee_process_id',
        'process_template_task_id',
        'title',
        'description',
        'due_date',
        'required',
        'order',
        'status',
        'completed_at',
        'assigned_to',
        'notes',
    ];

    protected $casts = [
        'due_date' => 'date',
        'completed_at' => 'datetime',
        'required' => 'boolean',
    ];

    public function process()
    {
        return $this->belongsTo(EmployeeProcess::class, 'employee_process_id');
    }

    public function templateTask()
    {
        return $this->belongsTo(ProcessTemplateTask::class, 'process_template_task_id');
    }

    public function assignee()
    {
        return $this->belongsTo(User::class, 'assigned_to');
    }
}
