コード例 #1
0
 /**
  * get all permissions of user by roles having that user
  * */
 private function get_permissions($roles)
 {
     $role_perm = new RolePermissions();
     $roles_ids = array_keys($roles);
     $permissions = $role_perm->join('permissions', 'permissions.pid', '=', 'role_permissions.pid')->whereIn('rid', $roles_ids)->select('permissions.name', 'permissions.pid')->lists('name', 'pid')->toArray();
     return $permissions;
 }
コード例 #2
0
 public function check_permission_access($permission_id, $user_roles)
 {
     $rolePermissionsCount = RolePermissions::where('pid', '=', $permission_id)->whereIn('rid', $user_roles)->count();
     if ($rolePermissionsCount > 0) {
         return true;
     }
     return false;
 }
コード例 #3
0
 /**
  * This function used to save permission matrix
  */
 public function savePermissionMatrix(Request $request)
 {
     access_check('manage_permission_matrix');
     RolePermissions::truncate();
     $permission_matrix = $request->input('pm');
     if (count($permission_matrix) > 0) {
         foreach ($permission_matrix as $permission) {
             $piece = explode('_', $permission);
             RolePermissions::create(array('pid' => $piece[0], 'rid' => $piece[1]));
         }
     }
     Session::flash('success', 'Permission Matrix Saved successfully.');
     return redirect('admin/permissionMatrix');
 }
コード例 #4
0
 public function run()
 {
     \Focalworks\Users\RolePermissions::create(['rid' => 2, 'pid' => 2]);
     \Focalworks\Users\RolePermissions::create(['rid' => 3, 'pid' => 2]);
 }