How to Get Current URL with Parameters in Laravel?

By Hardik Savani April 16, 2024 Category : Laravel

We sometimes require to get full url path with query string parameters that way we can perform on it. So we can get current url with also all parameter using several method of laravel 6, laravel 7, laravel 8, laravel 9, laravel 10 and laravel 11.

There are several option to get full url with query string as listed bellow:

  • URL Facade
  • Request Facade
  • $request Object

I give you three way to get full path with parameters, so you can see as bellow:

Example 1:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use URL;

class ItemController extends Controller

{

/**

* Display a listing of the resource.

*/

public function index(Request $request)

{

$fullURL = URL::full();

dd($fullURL);

}

}

Example 2:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ItemController extends Controller

{

/**

* Display a listing of the resource.

*/

public function index(Request $request)

{

$fullURL = $request->fullUrl();

dd($fullURL);

}

}

Example 3:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ItemController extends Controller

{

/**

* Display a listing of the resource.

*/

public function index(Request $request)

{

$fullURL = Request::fullUrl();

dd($fullURL);

}

}

I hope it can help you...

Tags :
Shares