dsfsw1233
2015-11-04 20:15
浏览 150
已采纳

如何在laravel 5.1中获取中间件中的路由

How can get collection of route thats registered in a middleware? In laravel 4.2 I can get collection of filters for each route like this:

$routeCollection = Route::getRoutes();
$filterName = "Visit";
$routeHasFilter = array();
foreach ($routeCollection as $route){
    $filters = $route->beforeFilters();
    if (count($filters) >= 1) {
         $filters = array_keys($filters);
         if (in_array($filterName, $filters))
             $routeHasFilter[] = $route;
    }
}

How can I find routes in laravel 5.1 with middleware?

图片转代码服务由CSDN问答提供 功能建议

如何获取在中间件中注册的路由集合? 在laravel 4.2中我可以为每个集合获取过滤器 这样的路线:

  $ routeCollection = Route :: getRoutes(); 
 $ filterName =“Visit”; 
 $ routeHasFilter = array(); 
foreach($  routeCollection as $ route){
 $ filters = $ route-> beforeFilters(); 
 if(count($ filters)> = 1){
 $ filters = array_keys($ filters); 
 if(n)  in_array($ filterName,$ filters))
 $ routeHasFilter [] = $ route; 
} 
} 
   
 
 

如何在laravel 5.1中查找路径 中间件?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题