In this small post, i wanted to show you how you can get current url or base url with parameters in your controller file or blade view file of laravel 5.7 project. So laravel 5.7 provide several way to get current app path using fullUrl(), current(), url() and segment() of request object. You can easily get by request object.
Laravel 5.7 provide Request and URL facade for getting request data. So we can simply get those current url using Request and URL facade. we can also get full url means you can get query string of url too. So i give you one by one both example As listed bellow:
Get Current URL with Parameters:
$currentURL = \Request::fullUrl();
Get Current URL without Parameters:
$currentURL = \URL::current();
$currentURL = \Request::url();
Get Only Parameters:
//Example URL: www.domain.tld/post/list?page=2
$parameters = \Request::segment(3);
I hope you found your solutions....
Do you like below Tutorials ?
- Jquery Delete Table Row on Click Event Example
- Laravel Eloquent Eager Load Count Relation Example
- Laravel Eloquent Eager Loading with Where Condition
- Laravel Eloquent Eager Loading Select Columns Example
- How to Toggle a Div on Button Click using Jquery?
- PHP Array Remove Multiple Elements by Key Example
- Laravel - How to Set Lifetime Expiration Time of Passport Access Token?
- Godaddy Shared Hosting Increase PHP Memory