How to get route action name in laravel?

0 votes

I'm trying to get the current route action, but I'm not sure how to go about it. In Laravel 4 I was using Route::currentRouteAction() but now it's a bit different.

I'm trying to do Route::getActionName() in my controller but it keeps giving me method not found.

<?php namespace App\Http\Controllers;

use Route;

class HomeController extends Controller
{
    public function getIndex()
    {
        echo 'getIndex';
        echo Route::getActionName();
    }
}
Sep 27 in Laravel by kartik
• 30,630 points
30 views

1 answer to this question.

0 votes

Hello @kartik,

To get action name, you need to use:

echo Route::getCurrentRoute()->getActionName();

and not

echo Route::getActionName();

Hope it helps!!
Thank you!!

answered Sep 27 by Niroj
• 66,420 points

Related Questions In Laravel

0 votes
4 answers

How to get user's IP address in Laravel?

Use $clientIP = request()->ip(); READ MORE

answered Sep 21 in Laravel by aakash
• 230 points
7,277 views
0 votes
1 answer

.How to turn off CSRF protection for a particular route in Laravel?

Hey, We can add that particular URL or ...READ MORE

answered Mar 24 in Laravel by Niroj
• 66,420 points
886 views
0 votes
1 answer

How to get distinct values for non-key column fields in Laravel?

Hello @kartik In eloquent you can use this $users ...READ MORE

answered Mar 30 in Laravel by Niroj
• 66,420 points
4,541 views
0 votes
1 answer

How to get all pending jobs in laravel queue on redis?

Hello @kartik, Here is the way I do ...READ MORE

answered Apr 6 in Laravel by Niroj
• 66,420 points
1,333 views
0 votes
1 answer

Uncaught Error: Bootstrap's JavaScript requires jQuery

Hello @kartik, You have provided wrong order for ...READ MORE

answered Apr 28 in JQuery by Niroj
• 66,420 points
3,062 views
0 votes
1 answer

How to make Bootstrap popover Appear/Disappear on hover instead of click?

Hello @kartik, Set the trigger option of the popover to hover instead ...READ MORE

answered May 12 in JQuery by Niroj
• 66,420 points
226 views
0 votes
1 answer

How to enable Bootstrap tooltip on disabled button?

Hii @kartik, You can wrap the disabled button ...READ MORE

answered May 12 in JQuery by Niroj
• 66,420 points
803 views
+1 vote
2 answers

How to set cache false for getJSON in jQuery?

You can't pass any configuration parameters to ...READ MORE

answered Oct 7 in JQuery by Amit
• 140 points
227 views
0 votes
1 answer

How to get a list of registered route paths in Laravel?

Hello, Route::getRoutes() returns a RouteCollection. On each element, you can ...READ MORE

answered Mar 31 in Laravel by Niroj
• 66,420 points
262 views
0 votes
1 answer

How to identify wheather the request is HTTP GET or HTTP POST in Laravel?

Hey, In order to identify the type of ...READ MORE

answered Mar 19 in Laravel by Niroj
• 66,420 points
109 views