Retract the role from the given model(s).

@param  string|\Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection  $model
@param  array|null  $keys
@return $this
189495
public function retractFrom($model, array $keys = null)
    {
        list($model, $keys) = Helpers::extractModelAndKeys($model, $keys);

        $query = $this->newBaseQueryBuilder()
            ->from(Models::table('assigned_roles'))
            ->where('role_id', $this->getKey())
            ->where('entity_type', $model->getMorphClass())
            ->whereIn('entity_id', $keys);

        Models::scope()->applyToRelationQuery($query, $query->from);

        $query->delete();

        return $this;
    }
691007
public function clear($keys = null)
    {
        if (is_null($keys)) {
            $this->items = [];

            return;
        }

        $keys = (array) $keys;

        foreach ($keys as $key) {
            $this->set($key, []);
        }
    }
165218
public function detach(Model $model, $relation, $ids = array(), $touch = true)
    {
        return $model->{$relation}()->detach($ids, $touch);
    }
439057
public function remove($key, Model $model)
    {
        if (false === $this->isHasMany($key)) {
            return $this;
        }
        if (true === $this->isInverse($key)) {
            throw ModelException::cannotModifyInverse($this, $key);
        }
        $this->touch();
        $collection = $this->hasManyRelationships->get($key);
        $collection->remove($model);
        $this->doDirtyCheck();
        return $this;
    }
719492
public function detach($model, string $relation, Model $value)
    {
        if (! $model instanceof Model) {
            $model = $this->find($model);
        }

        $model->$relation()->detach($value);
    }
643524
public function unlinkMany() {
        $models = func_get_args();

        if (is_array($models[0])) {
            $models = $models[0];
        }

        foreach ($models as $model) {
            $this->unlink($model);
        }

        return $this;
    }
130375
public function clear($key)
    {
        if (true === $this->isHasOne($key)) {
            return $this->setHasOne($key, null);
        }
        if (true === $this->isInverse($key)) {
            throw ModelException::cannotModifyInverse($this, $key);
        }
        if (true === $this->isHasMany($key)) {
            $collection = $this->hasManyRelationships->get($key);
            $collection->clear();
            $this->doDirtyCheck();
            return $this;
        }
        return parent::clear($key);
    }
757789
public function detachRole(...$roles)
    {
        $this->eachRole($roles, function($role) {
            if ($this->hasRole($role)) {
                $this->roles()->detach($role->id);
            }
        });

        return $this;
    }
837070
public function forgetMany(array $keys)
    {
        $this->connection()->del($this->prefixKeys($keys));

        return array_fill_keys($keys, true);
    }
667027
protected function getFormFieldValuesFromModel(Model $model, array $keys)
    {
        $values = [];

        foreach ($keys as $key) {

            $field    = $this->getModelFormFieldDataForKey($key);
            $instance = $this->getFormFieldStoreStrategyInstanceForField($field);

            $instance->setFormFieldData($field);
            $instance->setParameters(
                $this->getFormFieldStoreStrategyParametersForField($field)
            );

            // If we're creating a new model, pre-select the form field for the active list parent
            if ( ! $model->exists && $this->isFieldValueBeDerivableFromListParent($field->key)) {

                try {
                    $values[ $key ] = $instance->valueForListParentKey($this->getListParentRecordKey());

                    // @codeCoverageIgnoreStart
                } catch (Exception $e) {
                    $message = "Failed retrieving value for form field '{$key}' (using " . get_class($instance)
                             . " (valueForListParentKey)): \n{$e->getMessage()}";

                    throw new StrategyRetrievalException($message, $e->getCode(), $e);
                    // @codeCoverageIgnoreEnd
                }

                continue;
            }

            try {
                $values[ $key ] = $instance->retrieve($model, $field->source ?: $field->key);

                // @codeCoverageIgnoreStart
            } catch (Exception $e) {
                $message = "Failed retrieving value for form field '{$key}' (using " . get_class($instance)
                         . "): \n{$e->getMessage()}";

                throw new StrategyRetrievalException($message, $e->getCode(), $e);
                // @codeCoverageIgnoreEnd
            }
        }

        return $values;
    }
1121750
public function reduce(...$keys)
    {
        $keys = $this->normalizeKeys($keys);

        foreach ($this->keys() as $key) {
            if (!in_array($key, $keys, true)) {
                $this->remove($key);
            }
        }

        return $this;
    }
612064
protected function invalidate(Model $model): void
    {
        $key = $this->prefix . ":" . $model->getKey();
        if ($this->cacheRepository->has($key)) {
            $this->cacheRepository->forget($key);
        }
        $this->cacheRepository->forget("$this->prefix.:all");
    }
43543
public function revertModel($model)
    {
        if (!$model->is_destroy) {
            $model->destroy();
        }
        $this->pool[$model->core_name]->push($model);
    }
438852
protected function setForeignKeysToNull(Model $model, Relation $relation, array $keys)
    {
        if ( ! count($keys)) return;

        $key           = $this->normalizeForeignKey(head($keys));
        $model->{$key} = null;

        if (    count($keys) > 1
            &&  (   $relation instanceof MorphTo
                ||  $relation instanceof MorphOne
                ||  $relation instanceof MorphMany
            )
        ) {
            $key           = $this->normalizeForeignKey(array_values($keys)[1]);
            $model->{$key} = null;
        }

        $model->save();
    }
314804
public function removeDataKeyObj( $model, $meta ) {

		$config = $model->getDataMeta( 'data' );
		$rkey	= $meta->key;

		unset( $config->$rkey );

		$model->updateDataMeta( 'data', $config );

		$model->refresh();

		return $model;
	}
1001234
public function addEagerConstraints(array $models)
    {
        // We'll grab the primary key name of the related models since it could be set to
        // a non-standard name and not "id". We will then construct the constraint for
        // our eagerly loading query so it returns the proper models from execution.
        $key = $this->related->getTable().'.'.$this->ownerKey;

        $whereIn = $this->whereInMethod($this->related, $this->ownerKey);

        $this->query->{$whereIn}($key, $this->getEagerModelKeys($models));
    }
1323481
public function removeModel(ModelInterface $model): ModelCollectionInterface
    {
        if (isset($this->models[$model->getId()])) {
            $this->propertyReflection->setValue($model, null);

            unset($this->models[$model->getId()]);
        }

        return $this;
    }