From 013061c1d6a646d45ab023a43fc91d62ed67b3b6 Mon Sep 17 00:00:00 2001 From: Juan Felipe Duarte <70235683+DuarteJFelipe@users.noreply.github.com> Date: Fri, 17 Oct 2025 16:24:46 -0500 Subject: [PATCH] Show public and local IP addresses in Livewire view Added properties and event listener to ShowIpTest component to display both public IP (from Laravel) and local IP (from JavaScript). Updated Blade view to show both IPs and included a script to detect local IP using WebRTC and dispatch it to Livewire. --- app/Http/Livewire/ShowIpTest.php | 17 ++++++++-- .../views/livewire/show-ip-test.blade.php | 34 +++++++++++++++++-- 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/app/Http/Livewire/ShowIpTest.php b/app/Http/Livewire/ShowIpTest.php index 7e621fd..ebf56ea 100644 --- a/app/Http/Livewire/ShowIpTest.php +++ b/app/Http/Livewire/ShowIpTest.php @@ -7,10 +7,23 @@ use Illuminate\Support\Facades\Request; class ShowIpTest extends Component { + public $public_ip; + public $local_ip; + + protected $listeners = ['setLocalIP' => 'setLocalIP']; + + public function mount() + { + $this->public_ip = Request::ip(); + } + + public function setLocalIP($data) + { + $this->local_ip = $data['ip']; + } + public function render() { - dd($ip = Request::ip()); - return view('livewire.show-ip-test'); } } diff --git a/resources/views/livewire/show-ip-test.blade.php b/resources/views/livewire/show-ip-test.blade.php index db86de0..0ef3005 100644 --- a/resources/views/livewire/show-ip-test.blade.php +++ b/resources/views/livewire/show-ip-test.blade.php @@ -1,3 +1,33 @@ -
- {{-- Close your eyes. Count to one. That is how long forever feels. --}} +
+
+

IPs del Usuario

+ +
+

IP pública (Laravel): {{ $public_ip }}

+

IP local (JavaScript): {{ $local_ip ?? 'Detectando...' }}

+
+
+ +