<?php

namespace App\Models;

use App\Enums\PriorityStatus;
use App\Enums\TodoProgress;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Todo extends Model
{
    use HasFactory;

    protected $table = 'todo';

    protected $fillable = [
        'name',
        'status',
        'description',
        'image_url',
        'due_date',
        'priority',
    ];

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    protected function casts(): array
    {
        return [
            'status' => TodoProgress::class,
            'due_date' => 'date',
            'priority' => PriorityStatus::class,
        ];
    }
}
