Files
sirpremiumv2/resources/views/livewire/show-saving-ip.blade.php
T
Juan Felipe Duarte 4a44dbc1c1 Implement device and IP tracking for users
Added Device and UserIp models and migrations to store device fingerprints and user IPs with expiration. Updated ShowSavingIp Livewire component and view to capture and persist both IP and device fingerprint. Introduced a scheduled command to clean expired user IPs and registered it in the console kernel. Removed the old migration for storing IPs directly on the users table.
2025-10-25 09:18:56 -05:00

36 lines
1.1 KiB
PHP

<div
x-data="{
async getData() {
try {
// Obtener IP pública
const ipRes = await fetch('https://api.ipify.org/?format=json');
const ipData = await ipRes.json();
// Cargar librería Fingerprint
const fpModule = await import('https://openfpcdn.io/fingerprintjs/v3');
const fp = await fpModule.load();
const result = await fp.get();
const fingerprint = result.visitorId;
// Emitir ambos valores a Livewire
$wire.emit('setDeviceData', { ip: ipData.ip, fingerprint });
} catch (e) {
console.error('Error obteniendo IP/Fingerprint:', e);
}
}
}"
x-init="getData()"
wire:poll.visible.delay.600000ms
class="py-4"
>
<p class="text-sm text-gray-600">
@if($ip_address)
Tu IP actual: <strong>{{ $ip_address }}</strong><br>
ID del dispositivo: <strong>{{ $device_fingerprint }}</strong>
@else
Obteniendo IP y dispositivo...
@endif
</p>
</div>