<?php

namespace App\Models;

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

class GarmentType extends Model
{
    use HasFactory;

    protected $table = 'garment_types';

    protected $fillable = [
        'code',
        'name',
        'sort_order',
        'default_load_type_id',
        'is_active',
    ];

    protected $casts = [
        'sort_order' => 'integer',
        'default_load_type_id' => 'integer',
        'is_active' => 'boolean',
    ];

    public function ordenLavanderiaDetalles(): HasMany
    {
        return $this->hasMany(OrdenLavanderiaDetalle::class, 'garment_type_id');
    }

    public function defaultLoadType(): BelongsTo
    {
        return $this->belongsTo(LoadType::class, 'default_load_type_id');
    }
}
