如何在过滤器中获取当前路由名称?我试过使用Route::currentRouteName();,但它是空的。
Route::filter('belongsToUser', function(){
dd( Route::currentRouteName() );
exit;
});例如,路由查找:
Route::get('/openTicket/{id}', array('before' => 'auth|belongsToUser', 'uses' => 'MyController@MyAction'));发布于 2014-03-22 14:09:18
您的路由没有命名,因此难怪路由名为null。您需要一个as参数。
Route::get('/openTicket/{id}', array(
'as' => 'yourRouteName',
'before' => 'auth|belongsToUser',
'uses' => 'MyController@MyAction'));http://laravel.com/docs/routing#named-routes
https://stackoverflow.com/questions/22578467
复制相似问题