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.
30 lines
507 B
PHP
30 lines
507 B
PHP
<?php
|
|
|
|
namespace App\Http\Livewire;
|
|
|
|
use Livewire\Component;
|
|
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()
|
|
{
|
|
return view('livewire.show-ip-test');
|
|
}
|
|
}
|