我使用laravel 4開發一個網站,並試圖實現使用哨兵2.我需要如何構建以下幫助我的ACL:Laravel 4和哨兵2 ACL結構和訪問控制水平
我有對於角色HR以下權限:
Staffs|View staff details
Staffs|Register new staff
Staffs|Edit staff details
Staffs|Delete staff details
對應於下列路線:
//get route to staffs landing page
Route::get('staffs/view-staffs', '[email protected]');
//post routes
Route::post('staffs/add-staff', '[email protected]');
Route::post('staffs/update-staff', '[email protected]');
Route::post('staffs/delete-staff', '[email protected]');
我需要訪問控制以下:
鏈接在我的菜單上查看員工:如果全部員工權限被禁用,請禁用鏈接。這就是我如何做它:
if($user->hasAnyAccess(array('Staffs|View staff details', 'Staffs|Register new staff', 'Staffs|Edit staff details', 'Staffs|Delete staff details'))) { //display menu link }
我的路線:如果所有工作人員的權限被禁用,禁用「員工/」
//For this, i have no idea how to restrict routes based on my permissions //But i don't want to do it like i did in (1) within my controllers
禁止的行動,corresbond到按鈕下下跌的所有路由禁用許可
//same as no (1)
哎,流量看起來很酷..讓我嘗試實現..回來.. – aiiwa