How to Get Current URL in Laravel?
This tutorial shows you laravel get current url in controller. I would like to share with you laravel get current url in view. This post will give you simple example of get current url in laravel . it's simple example of laravel get current url. Here, Creating a basic example of get current page url in laravel.
Here is few examples you may use to get current route and url data. The methods will automatically use the schemes(http or https) from url.
Get Current URL in Laravel:
Example 1: current() with Helper
$currentURL = url()->current();
dd($currentURL);
Example 2: full() with Helper(with query string parameters)
$currentURL = url()->full();
dd($currentURL);
Example 3: current() with Facade
$currentURL = URL::current();
dd($currentURL);
Example 4: full() with Facade(with query string parameters)
$currentURL = URL::full();
dd($currentURL);
Example 5: using Request
$currentURL = Request::url();
dd($currentURL);
It will help you...
- How to Notifications With database Driver in Laravel 11?
- How to Send Email Via Notification in Laravel 11?
- How to Install and Configure Laravel 11 Debugbar?
- How to Like Dislike System in Laravel 11?
- How to Paginate a Model with Relationship in Laravel 11?
- Laravel 11 Upload Files to Amazon S3 Example
- Laravel 11 Send WhatsApp Messages Example
- Laravel 11 Rest API Authentication Using JWT Tutorial