示例#1
0
 /**
  * Check roles have all permission (root permission)
  *
  * @param  $user
  * @return boolean
  */
 public static function isAllPermission($user)
 {
     $userId = $user->id;
     $listRole = (new RoleUser())->getUserRole($userId);
     if (empty($listRole)) {
         return false;
     }
     foreach ($listRole as $role) {
         $permissionRoot = PermissionRole::where(['role_id' => $role, 'permission_id' => 1])->first();
         if (!empty($permissionRoot) && $permissionRoot->status == 1) {
             return true;
         }
     }
     return false;
 }
 /**
  * Check role is have all permission action
  *
  * @param Request
  * @return Response
  */
 public function checkAllPerm($id = null)
 {
     if (!Role::find($id)) {
         return response()->json(null, 404);
     }
     $permissionRoot = PermissionRole::where(['role_id' => $id, 'permission_id' => 1])->first();
     if (!empty($permissionRoot) && $permissionRoot->status == 1) {
         $isAll = true;
     } else {
         $isAll = false;
     }
     $roles = ['id' => (int) $id, 'type' => 'permissions', 'isAll' => $isAll];
     return response()->json(arrayView('gcl.gclusers::nodePermission/read', ['node' => $roles]), 200);
 }