ItSolutionStuff.com

How to Get Current URL with Parameters in Laravel?

By Hardik Savani • April 16, 2024
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: Laravel
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Laravel Download File from URL to Storage Example

Read Now →

Laravel Pagination Pretty URL Example

Read Now →

Laravel Get Next and Previous Record with URL Example

Read Now →

How to Remove index.php from url in Laravel?

Read Now →

Multiple orWhere Condition in Laravel Eloquent

Read Now →

Laravel URL Validation Rule Example

Read Now →

How to Get Current Controller Name in View Laravel?

Read Now →

How to Get Current URL in Laravel?

Read Now →

How to Get File Size from Storage in Laravel?

Read Now →

How to Redirect to External URL in Laravel?

Read Now →

How to Get Base URL in Laravel?

Read Now →

How to Get URL Segment in Laravel?

Read Now →

How to Get Current Route Name in Laravel?

Read Now →