<?php

declare(strict_types=1);

namespace Maestro\Core\Modules\HourRegistration\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Maestro\Core\Support\AuthUserResolver;

class HourTask extends Model
{
    protected $table = 'hour_tasks';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'hour_project_id',
        'title',
        'override_lead_id',
        'is_active',
    ];

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return ['is_active' => 'boolean'];
    }

    /**
     * @return BelongsTo<HourProject, HourTask>
     */
    public function project(): BelongsTo
    {
        return $this->belongsTo(HourProject::class, 'hour_project_id');
    }

    /**
     * @return BelongsTo<Model, HourTask>
     */
    public function overrideLead(): BelongsTo
    {
        return $this->belongsTo(AuthUserResolver::eloquentModelClass(), 'override_lead_id');
    }
}
