how to get current route name in blade file laravel 5.6
11,566
Solution 1
You can reload current page like this:
onclick="window.location.reload()"
There is no need to set current route in blade it's possible with javascript abilities.
Solution 2
With Below code you can know more about your current route.
$route = Route::current();
$name = Route::currentRouteName();
$action = Route::currentRouteAction();
Reference : Link
Hope it will help!
Solution 3
Best way to get current url in Laravel blade:
onclick="window.location='{{ Request::url() }}'"
Author by
debrata
Updated on June 05, 2022Comments
-
debrata almost 2 years
I want to reload my current page with onclick function, for this how to get my current route name in blade file.
This is my code:
<li class="dropdown user user-menu" onclick="window.location='{{ Route::current() }}'" style="cursor: pointer;"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <i class="livicon" data-name="refresh" data-loop="true" data-color="#42aaca" data-hovercolor="#42aaca" data-size="28"></i> </a> </li>
What is the best way to get the current route?
I want to use it on function
onclick
. -
xperator about 5 yearsThanks a lot. I was looking for this for a long time. Couldn't find it in docs on api guide