How to Fix Stream Timeout in Laravel: Effective Solutions with Code Examples
In this comprehensive tutorial, you'll master the art of retrieving the current route name using Laravel versions 6 through 10. Unveil multiple strategies to effortlessly fetch the route name within controllers, middleware, or blade files. Let's embark on this journey:
1. You can get the route name using the route facade in the controller or middleware
use Illuminate\Support\Facades\Route;
public function index(){
$routeName = Route::currentRouteName();
dd($routeName);
}
2. Using request facade to get the current route name
public function index(){
$routeName = \Request::route()->getName();
dd($routeName);
}
Similarly, you can also use in blade file to get the current route
{{ Route::currentRouteName() }}
Thanks for your time, hope it will help you to getting the route name in the controller, middleware or in the view where you want.
Subscribe to the Email Newsletter