Created
September 29, 2019 15:58
-
-
Save httpspace/15f7103b700297848d978fa298a40d96 to your computer and use it in GitHub Desktop.
權限舉例
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//角色權限表 | |
$user_role = [ | |
'1' => [ | |
'name' => '管理員', | |
'permission' => [ | |
'user_list', //可以看使用者列表 | |
'user_edit', //可以編輯使用者 | |
'user_delete', //可以刪除使用者 | |
] | |
], | |
'2' => [ | |
'name' => '網站管理員', | |
'permission' => [ | |
'user_list', | |
'user_edit', | |
] | |
], | |
'3' => [ | |
'name' => '網站會員', | |
'permission' => [ | |
'user_list', | |
] | |
] | |
]; | |
//取得資料 | |
$data = API->getUserInfo(); | |
$data = [ | |
'info' => [ | |
'name' => '王大明' | |
], | |
'permission' => [ | |
'user_list', | |
'user_edit', | |
] | |
]; | |
//處理 | |
{% if(user.data.permission.indexOf("user_edit") !== -1) %} | |
<a href="/user/edit"><button>修改會員</button></a> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment