andriajah Thu Mar 2022 1 year ago

Contoh Get Client IP Address Laravel 9

Dalam tutorial singkat ini kita akan membahas laravel 9 get client ip address. Anda akan belajar laravel 9 mendapatkan alamat ip. Kami akan menggunakan cara mendapatkan alamat ip di laravel 9. Anda dapat melihat cara mendapatkan alamat ip klien di laravel 9. Baiklah, mari kita masuk ke langkah-langkahnya.

 

Disini saya akan memberikan 4 cara mendapatkan IP Address client di aplikasi laravel 9.

Contoh 1:

$clientIP = request()->ip();   
   
dd($clientIP);

 

Contoh 2:

<?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);
    }
}

 

Contoh 3:

$clientIP = \Request::ip();
  
dd($clientIP);

 

Contoh 4:

$clientIP = \Request::getClientIp(true);
  
dd($clientIP);

 

laravel 9 laravel laravel tutorial get ip address laravel