DEV Community 👩‍💻👨‍💻

Techsolutionstuff
Techsolutionstuff

Posted on • Originally published at techsolutionstuff.com

How to Get Current URL in Laravel

In this article, we will see how to get the current URL in laravel. if you want to get the current page URL in laravel 8 then we can use many methods such type current(), full(), request(), url(). Here I will give you an example of laravel get current URL. In this example, I have used helper and function.

So, le's see laravel 8 get current url, get current page url in laravel 8, get full url in laravel 8, find current url in laravel 8, laravel 8 get url path, how to get current url in laravel controller, how to get current url in laravel blade

full() with Helper and Query string parameters

$currenturl = url()->full();

dd($currenturl);
Enter fullscreen mode Exit fullscreen mode

Read Also : Laravel 8 Socialite Login with Facebook Account


current() with Helper

$currenturl = url()->current();

dd($currenturl);
Enter fullscreen mode Exit fullscreen mode

using Request

$currenturl = Request::url();

dd($currenturl);
Enter fullscreen mode Exit fullscreen mode

Read Also : Laravel 8 Autocomplete Search from Database


current() with Facade

$currenturl = URL::current();

dd($currenturl);
Enter fullscreen mode Exit fullscreen mode

full() with Facade and Query string parameters

$currenturl = URL::full();

dd($currenturl);
Enter fullscreen mode Exit fullscreen mode

Read Also : Google Line Chart Example in Laravel 8


Get Previous URL in Laravel :

$pre_url= url()->previous();

dd($pre_url);
Enter fullscreen mode Exit fullscreen mode

Get Current Route in Laravel :

$cur_route = Route::current()->getName();

dd($cur_route);
Enter fullscreen mode Exit fullscreen mode

You might also like :

Oldest comments (0)

Join the One Year Club

You can earn this badge by being a registered member of the DEV Community for at least one year. Create an account and get started today.