Laravel 10, the client's IP address allows you to track and analyze user behavior. By logging IP addresses, you can gain insights into user demographics, geolocation, and traffic patterns.
Add Code in Controller:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class UserController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
$clientIP = $request->ip();
dd($clientIP);
OR
$clientIP = \Request::ip();
dd($clientIP);
OR
$clientIP = \Request::getClientIp(true);
dd($clientIP);
}
}
Here, Diffrent ways to print ip address you can choose any method.
Thank You