简体   繁体   English

从Laravel 5.2中的route.php获取所有控制器和资源

[英]Get all the Controller & resources from the routes.php in Laravel 5.2

i have just started using Laravel. 我刚刚开始使用Laravel。 I want to get the all possible routes using routes & with in those routes whom ever they are going to controller. 我想使用路由&来获取所有可能的路由,并与他们将要控制的那些路由一起使用。 I would like to know what methods are they are using. 我想知道他们正在使用什么方法。

I want to get all the routes automatically which ever controller i create in my App/Http/Controllers . 我想自动获取我在App/Http/Controllers创建的所有控制器的所有路由。

I would like to create a permission system for different users level (Dynamic) so it will be easy for admin to create different users with different permissions. 我想为不同的用户级别(动态)创建一个权限系统,这样管理员可以轻松地创建具有不同权限的不同用户。

Is there any way i can do this? 有什么办法可以做到吗?

I would like to display like this: 我想这样显示:

1) A page will be there in my resources/views/users/premissions.blade.php . 1)在我的resources/views/users/premissions.blade.php会有一个页面。

2) There will be all the controller mentioned with individual name and its methods like: 2)将提到所有带有单独名称的控制器及其方法,例如:

PagesController PagesController

  • [checkbox] View [复选框]视图
  • [checkbox] Create [复选框]创建
  • [checkbox] Show [复选框]显示
  • [checkbox] Update [复选框]更新
  • [checkbox] Destroy [复选框]销毁

PostsController PostsController

  • [checkbox] View [复选框]视图
  • [checkbox] Create [复选框]创建
  • [checkbox] Show [复选框]显示
  • [checkbox] Update [复选框]更新
  • [checkbox] Destroy [复选框]销毁

3) Then user will select the checkbox to provide the permission to the user. 3)然后,用户将选中复选框以向用户提供权限。 From the above controller. 从上面的控制器。

Thank you! 谢谢! looking forward to get its solution. 期待获得解决方案。

I don't understand what you're trying to achieve, but you could get all routes with Route::getRoutes() . 我不明白您要实现的目标,但是您可以使用Route::getRoutes()获得所有路由。

Not tested in 5.2, but should do the work. 尚未在5.2中进行测试,但应该可以完成工作。

    foreach (Route::getRoutes() as $Route) {
        $Routes[] = [
            'methods' => $Route->getMethods(),
            'path' => $Route->getPath(),
            'action' => $Route->getActionName(),
        ];
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM