get current url laravel – How to get current URL in controller or view?

get current url laravel using url()->current(), url()->full(), URL::current(), URL::full(), Request::url() and url()->previous() Best Examples.

get current url laravel

You can get current url in laravel using following methods.

Get Current URL in Laravel:

Example 1: current() with Helper

$exampleTestURI = url()->current();
  
dd($exampleTestURI);

Example 2: full() with Helper(with query string parameters)

$exampleTestURI = url()->full();
    
dd($exampleTestURI);

Example 3: current() with Facade

$exampleTestURI = URL::current();
    
dd($exampleTestURI);

Example 4: full() with Facade(with query string parameters)

$exampleTestURI = URL::full();
    
dd($exampleTestURI);

Example 5: using Request

$exampleTestURI = Request::url();
  
dd($exampleTestURI);

Don’t Miss : laravel get current url

Get Previous URL in Laravel:

$results = url()->previous();
  
dd($results);

Get Current Route in Laravel:

$results = Route::current()->getName();
  
dd($results);

I hope you get an idea about get current url laravel.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment