<?php

namespace App\Models;

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

/**
 * Tipo de servicio / SLA: urgente, express, normal (antes tabla servicios / priority_levels).
 * No confundir con laundry_sale_products (artículos POS) ni con etapas (lavado, planchado).
 */
class TipoServicio extends Model
{
    /** @use HasFactory<TipoServicioFactory> */
    use HasFactory;

    protected static function newFactory(): TipoServicioFactory
    {
        return TipoServicioFactory::new();
    }

    protected $table = 'tipos_servicio';

    protected $fillable = [
        'code',
        'name',
        'sort_order',
        'semaphore_hours_red',
        'semaphore_hours_yellow',
    ];

    protected $casts = [
        'sort_order' => 'integer',
        'semaphore_hours_red' => 'integer',
        'semaphore_hours_yellow' => 'integer',
    ];

    public const CODE_URGENT = 'urgent';

    public const CODE_EXPRESS = 'express';

    public const CODE_NORMAL = 'normal';

    public function ordenesLavanderia(): HasMany
    {
        return $this->hasMany(OrdenLavanderia::class, 'tipo_servicio_id');
    }
}
