<?php

namespace App\Models;

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

class TaskTemplate extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id',
        'name',
        'frequency',
        'anchor_date',
        'anchor_weekday',
        'anchor_day_of_month',
        'description',
    ];

    protected $casts = [
        'anchor_date' => 'date:Y-m-d',
        'anchor_weekday' => 'integer',
        'anchor_day_of_month' => 'integer',
    ];

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