Laravel 5.5 get current url with parameters


Today, i am going to show you how to get current url, base url with parameter in your controller or view file. We may sometime need to get current url in controller method or maybe in blade file. So it's not difficult to do this thing in laravel 5.5 application.

Laravel 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();

dd($currentURL);

Get Current URL without Parameters:

$currentURL = \URL::current();

dd($currentURL);

OR

$currentURL = \Request::url();

dd($currentURL);

Get Only Parameters:

//www.domain.tld/post/list?page=2

$parameters = \Request::segment(3);

dd($parameters);

I hope you found your solutions....


August 25, 2017 | 1899 Viewer | Category : PHP Laravel

Related Posts: