Laratrust\Traits\LaratrustUserTrait::detachRole PHP Method

detachRole() public method

Alias to eloquent many-to-many relation's detach() method.
public detachRole ( mixed $role, $group = null ) : Illuminate\Database\Eloquent\Model
$role mixed
return Illuminate\Database\Eloquent\Model
    public function detachRole($role, $group = null)
    {
        if (is_object($role)) {
            $role = $role->getKey();
        }
        if (is_array($role)) {
            $role = $role['id'];
        }
        if (!is_object($group) && $group != null) {
            throw new InvalidArgumentException();
        }
        if (!is_null($group)) {
            $group = $group->getKey();
        }
        $this->roles()->wherePivot(Config::get('laratrust.group_foreign_key'), $group)->detach($role);
        $this->flushCache();
        return $this;
    }