duangan1945 2016-02-10 19:19
浏览 269
已采纳

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

i have just started using 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.

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.

2) There will be all the controller mentioned with individual name and its methods like:

PagesController

  • [checkbox] View
  • [checkbox] Create
  • [checkbox] Show
  • [checkbox] Update
  • [checkbox] Destroy

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. From the above controller.

Thank you! looking forward to get its solution.

  • 写回答

1条回答 默认 最新

  • douye5949 2016-02-10 20:00
    关注

    I don't understand what you're trying to achieve, but you could get all routes with Route::getRoutes().

    Not tested in 5.2, but should do the work.

        foreach (Route::getRoutes() as $Route) {
            $Routes[] = [
                'methods' => $Route->getMethods(),
                'path' => $Route->getPath(),
                'action' => $Route->getActionName(),
            ];
        }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀