DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 966,904 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
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 :

Latest comments (0)

πŸ‘‹ Hey, my name is Noah and I’m the one who set up this ad. My job is to get you to join DEV, so if you fancy doing me a favor, I’d love for you to create an account.

If you found DEV from searching around, here are a couple of our most popular articles on DEV: