<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Sitio extends Model
{
    use HasFactory;

    protected $table = 'sitios_embarcaciones';

    public $timestamps = false;

    protected $fillable = [
        'nombre',
        'responsable',
        'cantidad_personas',
        'tipo',
        'ubicacion',
        'activo',
        'observacion',
        'fechaCreacion',
        'fechaActualizacion',
        'cedulaEditor',
    ];

    protected static function booted(): void
    {
        static::addGlobalScope('tipo_sitio', static function (Builder $builder): void {
            $builder->where('tipo', 'sitio');
        });

        static::creating(static function (self $model): void {
            $model->tipo = 'sitio';
        });
    }
}
