【问题标题】:laravel 4 get controller method from routelaravel 4 从路由获取控制器方法
【发布时间】:2014-12-15 13:55:08
【问题描述】:

如果我有一条简单的路线

Route::get('foo', 'path\to\controller\MyController@bar');

当我在我的应用程序中时 - 是否有方法/函数可以返回所使用的控制器方法?即:bar

....有没有类似\Route::getCurrentControllerMethod()

【问题讨论】:

    标签: php laravel laravel-4 laravel-routing


    【解决方案1】:

    如果您只想从当前路由中获取bar,您应该使用:

    $method = explode('@', Route::currentRouteAction());
    $method = end ($method);
    

    【讨论】:

      【解决方案2】:

      尝试以下方法之一:

      Route::getCurrentRoute()->getAction();
      Route::currentRouteAction();
      Route::currentRouteName();
      

      http://forumsarchive.laravel.io/viewtopic.php?id=10095

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-05-21
        • 1970-01-01
        相关资源
        最近更新 更多