How to Get Current URL and Site URL in Laravel
In this quick example tutorial i will show you how we can get current url in Laravel. Sometimes we need to get full url path with query string parameters that way we can perform on it. So we can get current url with also all parameter using several method of laravel.
In this example we will also see how we can print current route name in laravel. How to get current route prefix name we will also see it in this example. Sometimes we need those thing to activate current menu item active.
Current URL in Laravel
Laravel provide URL facade that way we can get current URL.
$currentURL = URL::current();
SIte URL in Laravel
$url = URL::to("/"); or use $url = url('/');
Get current route name in laravel
$route = Route::current()->getName();
Get current route prefix name in laravel
$prefix = Request::route()->getPrefix();
Hope it can help you.