<?php

namespace App\Models;

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

class PlannedTask extends Model
{
    use HasFactory;

    protected $primaryKey = 'planned_task_id';

    protected $fillable = [
        'planned_date',
        'execution_date',
        'type',
        'note',
        'taskable_id',
        'taskable_type',
    ];

    protected $casts = [
        'planned_date' => 'date',
        'execution_date' => 'date',
    ];

    /**
     * Get the taskable model (Treatment or Harvest).
     */
    public function taskable(): MorphTo
    {
        return $this->morphTo();
    }
}
