我正在系统中创建角色管理模块。我在配置文件中获取模块权限。数组看起来像:
"user_management" => array:3 [▼
"display_name" => "Users"
"permissions" => []
"child" => array:2 [▼
"user_internal_management" => array:3 [▼
"display_name" => "Roam Users"
"permissions" => array:5 [▼
"browse_user_internal" => "Browse Roam Users"
"view_user_internal" => "View Roam Users"
"add_user_internal" => "Add Roam User"
"edit_user_internal" => "Edit Roam User"
"delete_user_internal" => "Delete Roam User"
]
"child" => []
]
"user_corporate_management" => array:3 [▼
"display_name" => "Client Users"
"permissions" => array:5 [▼
"browse_user_corporate" => "Browse Client Users"
"view_user_corporate" => "View Client Users"
"add_user_corporate" => "Add Client User"
"edit_user_corporate" => "Edit Client User"
"delete_user_corporate" => "Delete Client User"
]
"child" => []
]
]
]
user_management
是user_internal_management & user_corporate_management
的父级,而user_management
是permission
的子级
创建新角色时我想要什么,我只想显示登录用户在添加表单上具有的特定权限。
因此对于create函数,我得到了所有ID(已登录用户的权限)和parent> child > child
表的ID。
我想安排这个ID的数组,定义如上。
array:8 [▼
0 => 1
1 => 68
2 => 69
3 => 70
4 => 71
5 => 72
6 => 73
7 => 74
]
我得到了权限ID的数组,如;
-----------------------------
| id | desc | state |
-----------------------------
| 1 | desc 1 | Complete |
| 2 | desc 2 | Open |
| ... | ... | ... |
-----------------------------
我该怎么做??