<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Stancl\Tenancy\Database\Concerns\HasDomains;

class Tenant extends Model
{
    use HasDomains;

    protected $fillable = [
        'id_externo',
        'nombre',
        'ruc',
        'logo',
        'telefono',
        'email',
        'direccion',
        'ciudad',
        'tipo',
        'activo',
        'codigo_portal',
        'corte_facturacion_dia',
        'cruce_facturacion_dia',
    ];

    protected $casts = [
        'activo' => 'boolean',
    ];

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

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

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

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

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

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

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

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

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