In this little post, we will perceive how to get the current URL in Laravel, assuming you need to get the current page URL in Laravel, we can utilize numerous methods such as sort current(), full(), request(), URL().
Here I will give you all guide to get the current page URL in Laravel, in this model I have utilized aid and capacity just as so we should begin illustration of in what manner to get the current URL id in Laravel.
Example 1: full() with the Helper and Query string parameters
$currenturl = url()->full();
dd($currenturl);
Example 2: current() with the Helper
$currenturl = url()->current();
dd($currenturl);
Example 3: using the Request
$currenturl = Request::url();
dd($currenturl);
Example 4: current() with the Façade
$currenturl = URL::current();
dd($currenturl);
Example 5: full() with the Facade & Query string parameters.
$currenturl = URL::full();
dd($currenturl);
Get the Previous URL in Laravel
$pre_url= url()->previous();
dd($pre_url);
Get Current Route in Laravel
$cur_route = Route::current()->getName();
dd($cur_route);
I hope you will like the content and it will help you to learn How to Get Current URL in Laravel
If you like this content, do share.