Alias to eloquent many-to-many relation's detach() method.

@param mixed $role
422987
public function detachRole($role)
    {
        if (is_object($role)) {
            $role = $role->getKey();
        }

        if (is_array($role)) {
            $role = $role['id'];
        }

        $this->roles()->detach($role);

        self::clearCache();
    }
1054957
public function assignRoleBySlug(string $role)
    {
        return $this->roles()->save(
            HCAclRole::where('slug', $role)->firstOrFail()
        );
    }
603144
public static function removeIncludedRoles( core_kernel_classes_Resource $role)
    {
        $serial = self::buildIncludedRolesSerial($role);
        ServiceManager::getServiceManager()->get('generis/cache')->remove($serial);;

        // -- note: the cache might exist even if it was successfully
        // removed due to race conditions.
        // $returnValue = (file_exists(GENERIS_CACHE_PATH . $serial)) ? false : true;
        return true;
    }
625051
public function join(RoleInterface $role)
    {
        $this->roles()
            ->attach($role);

        return $this->is($role);
    }
1251945
public function syncRoles($roles, $detach = false)
    {
        foreach ($roles as $k => $slug) {
            // add dealer role to user
            $role = Role::where('keyword', $slug)->first();
            $this->roles()->syncWithoutDetaching([$role->id]);
        }

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

        $this->load('roles');

        return $this;
    }
309277
private static function get_role( $role ) {
		global $wp_roles;

		$role_obj = $wp_roles->get_role( $role );

		if ( ! $role_obj ) {
			WP_CLI::error( "'{$role}' role not found." );
		}

		return $role_obj;
	}
959430
public function prune($role = null)
    {
        if ($role) {
            $this->addUsingAlias(RolePeer::ID, $role->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }
49159
public function detachRole($roleSlug)
    {
        // add dealer role to user
        $role = Role::where('keyword', $roleSlug)->first();
        $this->roles()->detach([$role->id]);

        return $this->roles;
    }
147317
public function addRole(Role $role)
    {
        if (!in_array($role, $this->roles)) {
            $this->roles[] = $role;
            return true;
        }
        return false;
    }
375328
public function replaceRoles($roles)
    {
        $this->roles()->detach();

        $this->eventRemoveRole($roles);

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

        $this->eventAddRole($roles);

        return $this;
    }
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;
    }
584441
protected function findRole($role)
    {
        // Try to see if we have a role registered for the given
        // key so we can determine the role's inheritances.
        if (array_key_exists($role, $this->roles)) {
            return $this->roles[$role];
        }

        // If we couldn't find a registered role for the
        // given key, just return a new role object.
        return new SimpleRole($role);
    }
11135
public function deleteRole(Role $role)
    {
        $returnValue = $this->service->deleteRole($role);
        $this->signalDispatcher->emit(
            new DeleteRoleSignal(
                array(
                    'roleId' => $role->id,
                )
            )
        );

        return $returnValue;
    }
826577
public function attachRole($role, $granted = TRUE)
    {
        if($granted)
            return (!$this->grantedRoles()->get()->contains($role)) ? $this->roles()->attach($role, array('granted' => TRUE)) : true;
        else
            return (!$this->deniedRoles()->get()->contains($role)) ? $this->roles()->attach($role, array('granted' => FALSE)) : true;
    }
961594
public function assignRole(...$roles)
    {
        $roles = collect($roles)
            ->flatten()
            ->map(function ($role) {
                if (empty($role)) {
                    return false;
                }

                return $this->getStoredRole($role);
            })
            ->filter(function ($role) {
                return $role instanceof Role;
            })
            ->each(function ($role) {
                $this->ensureModelSharesGuard($role);
            })
            ->map->id
            ->all();

        $model = $this->getModel();

        if ($model->exists) {
            $this->roles()->sync($roles, false);
            $model->load('roles');
        } else {
            $class = \get_class($model);

            $class::saved(
                function ($object) use ($roles, $model) {
                    static $modelLastFiredOn;
                    if ($modelLastFiredOn !== null && $modelLastFiredOn === $model) {
                        return;
                    }
                    $object->roles()->sync($roles, false);
                    $object->load('roles');
                    $modelLastFiredOn = $object;
                });
        }

        $this->forgetCachedPermissions();

        return $this;
    }
164604
public function unassignRole($roleName, $userId)
    {
        $role = $this->role->findByName($roleName);
        $user = $this->model->find($userId);

        $user->roles()->detach($role);
    }