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 then we can use many methods such as type current(), full(), request(), url(). Also, you can get the current URL in laravel 6, laravel 7, and laravel 9.
Here, we will give you all examples to get the current page url in laravel. In this example, we have used the laravel helper function. Also, you can get the previous URL and full URL in laravel 6/7/8/9.
So, let's see laravel 7/8/9 get the current URL and get the full URL in laravel.
In this example, we will use the full() laravel helper function and get the full URL.
$currenturl = url()->full();
dd($currenturl);
In this example, we will use the url() function with the current() helper function and get the current URL.
$currenturlĀ = url()->current();
dd($currenturl);
In this example, we will get the url using the request method.
$currenturl = Request::url();
dd($currenturl);
In this example, we will use the URL facade and get the current URL.
$currenturl = URL::current();
dd($currenturl);
In this example, we will use the URL facade and get the full URL.
$currenturl = URL::full();
dd($currenturl);
In this example, we will use the url() function and get the previous URL.
$pre_url= url()->previous();
dd($pre_url);
Now, we will get the current route using the getName() function.
$cur_route = Route::current()->getName();
dd($cur_route);
You might also like:
Today in this post we will see multi step form example in laravel, here we will create laravel multi step form example.&...
Jul-21-2021
In this article, I'll show you how to read CSV files in Python. Using Python, we can easily read CSV files line by l...
Sep-18-2024
In this tutorial we will see laravel 8 socialite login with github account. explains how to integrate OAuth github...
Oct-25-2021
In this article, we will see how to back up the database in laravel 9 using spatie. Here, we will learn automatic&n...
Feb-08-2023