Laravel get ip address

2024-03-04 05:56:49 Suresh Laravel

How can we get the IP address of the user in Laravel

Hello friend in this post I going to show you how to get users IP address in Laravel 5.8 and save it is database.

Different Methods of Laravel to get IP address

1. $clientIP = \Request::ip();
2. $clientIP = \Request::getClientIp(true);
3. $clientIP = request()->ip();
4. public function index(Request $request){

Laravel get IP address and Save it in Database

public function trackUserActivity(Request $request){
  $user_activity=new UserActivity();  
  // getting logged in user info from laravel Auth
  // Getting ip address of remote user


This post is submitted by one of our members. You may submit a new post here.

Related Tricks