In this tutorial, we'll look at how to access the current URL in a Laravel Controller or view. Laravel includes several ways for obtaining the current uri.
In this tutorial, we will use Request::fullUrl() to access the current Uri of theLaravel Controller. Let's have a look at the simple steps below:
Step 1:Open your composer command prompt and execute the following command to create a new Laravel project
composer create-project --prefer-dist laravel/laravel currenturl |
Step 2: Now, Open your, welcome.blade.php file and add the following code to display the current uri
<p> Url: {{ Request::url() }} </p> |
Now open your application in the browser. The project URL will be displayed.
Article Contributed By :
|
|
|
|
970 Views |