48 lines
839 B
PHP
48 lines
839 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Ciudad extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
/**
|
|
* The table associated with the model.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $table = 'ciudades';
|
|
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'nombre',
|
|
'codigo',
|
|
'estado_id',
|
|
'activo'
|
|
];
|
|
|
|
/**
|
|
* The attributes that should be cast.
|
|
*
|
|
* @var array<string, string>
|
|
*/
|
|
protected $casts = [
|
|
'activo' => 'boolean',
|
|
];
|
|
|
|
/**
|
|
* Scope para obtener solo ciudades activas
|
|
*/
|
|
public function scopeActivas($query)
|
|
{
|
|
return $query->where('activo', true);
|
|
}
|
|
}
|