How to Get Current URL with Parameters in 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...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Laravel Download File from URL to Storage Example
- Laravel Pagination Pretty URL Example
- Laravel Get Next and Previous Record with URL Example
- How to Remove index.php from url in Laravel?
- Multiple orWhere Condition in Laravel Eloquent
- Laravel URL Validation Rule Example
- How to Get Current Controller Name in View Laravel?
- How to Get Current URL in Laravel?
- How to Get File Size from Storage in Laravel?
- How to Redirect to External URL in Laravel?
- How to Get Base URL in Laravel?
- How to Get URL Segment in Laravel?
- How to Get Current Route Name in Laravel?