delete a specified role.

@param  string $role
@return array
@throws \GuzzleHttp\Exception\BadResponseException
354789
public function deleteRole($role)
    {
        $params = [
            'role' => $role,
        ];

        $body = $this->request(self::URI_AUTH_ROLE_DELETE, $params);

        return $body;
    }
716007
public function demoteTo($role)
    {
        $transaction = static::getDb()->beginTransaction();
        try {
            $this->scenario = 'role';
            $this->role = $role;
            if (!$this->save()) {
                throw new Exception('User saving error!');
            }
            if (Podium::getInstance()->rbac->getRolesByUser($this->id)
                && !Podium::getInstance()->rbac->revoke(Podium::getInstance()->rbac->getRole(Rbac::ROLE_MODERATOR), $this->id)) {
                throw new Exception('User role revoking error!');
            }
            if (!Podium::getInstance()->rbac->assign(Podium::getInstance()->rbac->getRole(Rbac::ROLE_USER), $this->id)) {
                throw new Exception('User role assigning error!');
            }
            if ((new Query())->from(Mod::tableName())->where(['user_id' => $this->id])->exists()
                && !Podium::getInstance()->db->createCommand()->delete(Mod::tableName(), ['user_id' => $this->id])->execute()) {
                throw new Exception('Moderator deleting error!');
            }
            Activity::updateRole($this->id, User::ROLE_MEMBER);

            $transaction->commit();
            Log::info('User demoted', $this->id, __METHOD__);
            return true;
        } catch (Exception $e) {
            $transaction->rollBack();
            Log::error($e->getMessage(), null, __METHOD__);
        }
        return false;
    }
892956
public function deleteRole(Role $role)
    {
        $url = self::makeUrl($role->tenantId, $role->name);
        $this->service->prepAndSend($url, array(204), 'DELETE', null, false);
	}
204605
public function destroy(Request $request, Role $role)
    {
        $this->authorize('delete', Role::class);
        $role->deletePermissions($role->permissions);
        $role->deleteUsers($role->users);

        $role->delete();

        return redirect()->route('laralum::roles.index')->with('success', __('laralum_roles::general.role_deleted', ['id' => $role->id]));
    }
32768
public function downgradeFromRole(Role $role): bool
    {
        $auth = \Yii::$app->getAuthManager();
        if ($auth->revoke($role, $this->id)) {
            return true;
        }
        return false;
    }
639547
public function getRole($role) {
		
		if(false === is_string($role)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($role)), E_USER_ERROR);
		}

		foreach($this -> permissions as $type => $resources) {

			if($role === $type) {
				
				$p = new Resources();
				$p -> setResources($resources);

				return $p;
			}
		}

		return null;
	}
950592
public function removeRole($role)
    {
        if ( ! ($roleModel = $this->sentinel->findRoleBySlug($role))) {
            return false;
        }

        /** @var EloquentRole $roleModel */
        $roleModel->delete();

        $this->fireRoleChangeEvent();
        return true;
    }
129435
public function removeRole($role)
    {
        $this->roles()->detach($this->getStoredRole($role));

        $this->load('roles');

        return $this;
    }
19813
public function detachRole($role, $reload = true)
    {
        event(new DetachingRoleFromUser($this, $role));
        $results = $this->roles()->detach($role);
        event(new DetachedRoleFromUser($this, $role, $results));

        $this->loadRoles($reload);

        return $results;
    }
471498
public function listByRole(Role $role, $trashed = false)
    {
        $this->authorize(UsersPolicy::PERMISSION_LIST);

        $users = $role->users()->with('roles')
            ->protectAdmins()
            ->paginate(30);

        $title = trans('auth::users.titles.users-list')." - {$role->name} Role". ($trashed ? ' - '.trans('core::generals.trashed') : '');
        $this->setTitle($title);
        $this->addBreadcrumb($title);

        return $this->view('admin.users.list', compact('trashed', 'users'));
    }
793938
public function removeRole( core_kernel_classes_Resource $role)
    {
        $returnValue = (bool) false;
        
    	if (GENERIS_CACHE_USERS_ROLES == true && core_kernel_users_Cache::areIncludedRolesInCache($role)){	
    		
    		if ($role->delete(true) == true){ // delete references.
        		$returnValue = core_kernel_users_Cache::removeIncludedRoles($role);
        		
        		// We also need to remove all included roles cache that contain
        		// the role we just deleted.
        		foreach ($this->getAllRoles() as $r){
        			if (array_key_exists($role->getUri(), $this->getIncludedRoles($r))){
        				core_kernel_users_Cache::removeIncludedRoles($r);
        			}
        		}
        	}
        	else{
        		$roleUri = $role->getUri();
        		$msg = "An error occured while removing role '${roleUri}'. It could not be deleted from the cache.";
        		throw new core_kernel_users_Exception($msg);
        	}
        }
        else{
        	$returnValue = $role->delete(true);	// delete references to this role!
        }

        return (bool) $returnValue;
    }
360889
public function removeRole($role)
    {
        if ($role instanceof Role) {
            $role = $role->id;
        }

        if (false !== ($index = array_search($role, $this->attributes['roles']))) {
            unset($this->attributes['roles'][$index]);
        }

        return true;
    }
103120
public function deleteRole(APIRole $role)
    {
        if ($this->repository->hasAccess('role', 'delete') !== true) {
            throw new UnauthorizedException('role', 'delete');
        }

        $loadedRole = $this->loadRole($role->id);

        $this->repository->beginTransaction();
        try {
            $this->userHandler->deleteRole($loadedRole->id);
            $this->repository->commit();
        } catch (Exception $e) {
            $this->repository->rollback();
            throw $e;
        }
    }
1240864
public function removeRole(string $role): GroupInterface
    {
        if (false !== $key = array_search(mb_strtoupper($role), $this->roles, true)) {
            unset($this->roles[$key]);
            $this->roles = array_values($this->roles);
        }

        return $this;
    }
1258667
public function destroy($id)
    {
        // get role by id
        $role = Role::find($id);

        if (!$role) {
            return response()->json(null, 404);
        }

        // delete role
        $deleteRole = $role->delete();

        if (!$deleteRole) {
            return response()->json(null, 500); // @codeCoverageIgnore
        }

        return response()->json(null, 204);
    }
432725
public function removeRole(Role $role)
    {
        $this->initializeRoles();
        if ($this->hasRole($role)) {
            $roleIdentifier = $role->getIdentifier();
            unset($this->roles[$roleIdentifier]);
            $identifierIndex = array_search($roleIdentifier, $this->roleIdentifiers);
            unset($this->roleIdentifiers[$identifierIndex]);
        }
    }
483506
public static function findByRole(string $role): array
    {
        return static::find()->where(['id' => \Yii::$app->authManager->getUserIdsByRole($role)])->all();
    }