Get Current Route Name using Laravel Example

Today, We want to share with you Get Current Route Name using Laravel Example.In this post we will show you How to check current URL or Route, hear for Route::currentRouteName() returns the route name we will give you demo and example for implement.In this post, we will learn about How to get current route name path and action in laravel 5 with an example.

Get Current Route Name using Laravel Example

There are the Following The simple About Get Current Route Name using Laravel Example Full Information With Example and source code.

As I will cover this Post with live Working example to develop Laravel 5.5 Get Route Name in Controller, View and Middleware, so the php – How to get current route name in laravel 5? for this example is following below.

Also Read :  Laravel 5.7 CRUD Tutorial With Example from scratch

Example 1: Get current route name in Blade Files

Accessing The Current Route using Laravel

$route = Route::current();
dd($route);

$name = $route->getName();
dd($name);

$actionName = $route->getActionName();
dd($actionName);

$name = Route::currentRouteName();
dd($name);

$action = Route::currentRouteAction();
dd($action);

Using Request:

$route_liveName = Request::route()->getName());
print($route_liveName);

Using Route:

$route_liveName = Route::getCurrentRoute()->getPath();
print($route_liveName);

Example 2: get current route name using Laravel

return \Request::route()->getName(); 
// response membersDATA.index

return \Route::currentRouteName(); 
// response membersDATA.index

Example 3: get current route path using Laravel

 return \Route::getCurrentRoute()->getPath(); 
 // response membersDATA

Example 4: get current route action using Laravel

 return \Route::getCurrentRoute()->getActionName(); 
 //response App\Http\Controllers\[email protected]

Example 5: get a list of all routes using Laravel?

 $all_routes = \Route::getRoutes();
 foreach ($all_routes as $route) {
    echo $route->getPath().'<hr/>';
 }

Free Download Example – Pakainfo.com

Angular 6 CRUD Operations Application Tutorials

Read :

Also Read :  Laravel 5.7 Stripe Payment Gateway Example From Scratch

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Get Current Route Name using Laravel Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Gondaliya Jaydeep

Hi, I’m Jaydeep Gondaliya, PHP developer.Pakainfo.com is the most popular Programming & Web Development blog. Our mission is to provide the best online resources on programming and web development.Any visitors of this site are free to browse our tutorials, live demos, Examples and download scripts.If you have a project that you want to get started, launch quickly, contact me. Email : [email protected]