@param string $role

@return $this
172376
public function removeRole($role)
    {
        $key = array_search(strtoupper($role), $this->roles, true);
        if (false !== $key) {
            /** @var string $key */
            unset($this->roles[$key]);
            $this->roles = array_values($this->roles);
        }

        return $this;
    }
1054957
public function assignRoleBySlug(string $role)
    {
        return $this->roles()->save(
            HCAclRole::where('slug', $role)->firstOrFail()
        );
    }
696813
protected function insertRoles(array $roles)
    {
        foreach ($roles as $role) {
            if (null === $role->getParent()) {
                $this->addRole($role);
            } else {
                $parents   = [];
                $parents[] = $role->getParent()->getRoleId();
                $this->addRole($role, $parents);
            }
        }

        return $this;
    }
83602
public function addRole(string $role): UserInterface
    {
        $role = mb_strtoupper($role);

        if (!\in_array($role, $this->roles, true)) {
            $this->roles[] = $role;
        }

        return $this;
    }
1023675
public function revokeRole($role)
    {
        return $this->mapArray($role, function ($role) {

            $roleId = $this->parseRoleId($role);

            return $this->roles()->detach($roleId);
        });
    }
375328
public function replaceRoles($roles)
    {
        $this->roles()->detach();

        $this->eventRemoveRole($roles);

        $this->roles()->attach($roles);

        $this->eventAddRole($roles);

        return $this;
    }
197854
public function getRole($role = null)
    {
        /* @var $roleItem RoleInterface */
        foreach ($this->roles as $roleItem) {
            if ($role == $roleItem->getRole()) {
                return $roleItem;
            }
        }

        return null;
    }
849061
public function setRole($role)
    {
        $allowedValues = $this->getRoleAllowableValues();
        if (!in_array($role, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'role', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['role'] = $role;

        return $this;
    }
1339795
public function hasRole($role)
    {
        if (is_array($role)) {
            return in_array($this->attributes['role'], $role);
        }

        return $this->attributes['role'] == $role;
    }
934541
public function attachRoles($roles)
    {
        if ($roles instanceof Role) {
            $roles = [$roles->getKey()];
        }

        $this->roles()->sync($roles, false);

        unset($this->relations['roles']);

        return $this;
    }
862732
public function validateRole($role)
    {
        $roleValidator = new RoleValidator();
        $response = $roleValidator->validate($role);

        if (!$response) {
            $this->addError('role', 'Role must be a valid instance of Role class - ' . $roleValidator->getErrorsAsString());
        }

        return $response;
    }
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;
    }
1267809
protected function addRoles($roles)
    {
        foreach ($roles as $name => $parent) {
            if (!$this->hasRole($name)) {
                if (empty($parent) && !is_array($parent)) {
                    $parent = [];
                }
                $this->addRole(new GenericRole($name), $parent);
            }
        }

        return $this;
    }
1281147
public function addRole($role)
    {
        $role = strtoupper($role);
        if (static::ROLE_DEFAULT === $role) {
            return $this;
        }

        if (!$this->hasRole($role)) {
            $this->roles[] = $role;
        }

        return $this;
    }
1161907
public function createCreateStructFromRole(Role $role)
    {
        $createStruct = new RoleCreateStruct();

        $createStruct->identifier = $role->identifier;
        $createStruct->policies = $role->policies;

        return $createStruct;
    }
1042402
public function create(Role $role)
    {
        $this->authorize(UsersPolicy::PERMISSION_CREATE);

        $roles = $role->all();

        $this->setTitle($title = trans('auth::users.titles.create-user'));
        $this->addBreadcrumb($title);

        return $this->view('admin.users.create', compact('roles'));
    }
129435
public function removeRole($role)
    {
        $this->roles()->detach($this->getStoredRole($role));

        $this->load('roles');

        return $this;
    }