60 lines
1.2 KiB
PHP
60 lines
1.2 KiB
PHP
<?php namespace App\Models;
|
|
/**
|
|
* @copyright (c) 2025 Notsoweb Software (https://notsoweb.com) - All Rights Reserved
|
|
*/
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
/**
|
|
* Modelo Arco RFID
|
|
*
|
|
* Representa un arco lector RFID físico identificado por su dirección IP
|
|
*
|
|
* @author Moisés Cortés C. <moises.cortes@notsoweb.com>
|
|
*
|
|
* @version 1.0.0
|
|
*/
|
|
class Arco extends Model
|
|
{
|
|
protected $table = 'arcos';
|
|
|
|
protected $fillable = [
|
|
'nombre',
|
|
'ip_address',
|
|
'ubicacion',
|
|
'activo'
|
|
];
|
|
|
|
protected $casts = [
|
|
'activo' => 'boolean',
|
|
'created_at' => 'datetime',
|
|
'updated_at' => 'datetime'
|
|
];
|
|
|
|
/**
|
|
* Relación con detecciones
|
|
*/
|
|
public function detecciones(): HasMany
|
|
{
|
|
return $this->hasMany(Detection::class, 'arco_id');
|
|
}
|
|
|
|
/**
|
|
* Scope para obtener solo arcos activos
|
|
*/
|
|
public function scopeActivos($query)
|
|
{
|
|
return $query->where('activo', true);
|
|
}
|
|
|
|
/**
|
|
* Buscar arco por IP
|
|
*/
|
|
public static function buscarPorIp(string $ip): ?self
|
|
{
|
|
return self::where('ip_address', $ip)->first();
|
|
}
|
|
}
|