Remove the scope from a given query builder.

        :param builder: The query builder
        :type builder: eloquent.orm.builder.Builder

        :param model: The model
        :type model: eloquent.orm.Model
540331
def remove(self, builder, model):
        
        column = model.get_qualified_deleted_at_column()

        query = builder.get_query()

        wheres = []
        for where in query.wheres:
            # If the where clause is a soft delete date constraint,
            # we will remove it from the query and reset the keys
            # on the wheres. This allows the developer to include
            # deleted model in a relationship result set that is lazy loaded.
            if not self._is_soft_delete_constraint(where, column):
                wheres.append(where)

        query.wheres = wheres
255817
public function apply(Builder $builder, Model $model): void
    {
        if (method_exists($model, 'shouldApplyApprovedFlagScope') && $model->shouldApplyApprovedFlagScope()) {
            $builder->where('is_approved', 1);
        }
    }
842922
public function scopeOfUser(Builder $builder, Model $user): Builder
    {
        return $builder->where('user_type', $user->getMorphClass())->where('user_id', $user->getKey());
    }
1255872
public function scopeListifyScope(Builder $query)
    {
        if (method_exists($this, 'cleanListifyScopedQuery')) {
            $this->cleanListifyScopedQuery($query);
        }

        return $query->whereRaw($this->listifyScopeCondition());
    }
1278852
def get_query_builder(self, *args, **kwargs):
        
        query_builder = self.get_query_builder_class()
        return query_builder(*args, **kwargs)
853251
public function scopeWithheld(Builder $query)
    {
        return $query->where(function ($query)
        {
            $query->where('status', '<=', Node::DRAFT)
                ->orWhere(function ($query)
                {
                    $query->where('status', '<=', Node::PENDING)
                        ->where('published_at', '>', Carbon::now());
                });
        });
    }
675504
public function remove(Builder $query, Model $model)
    {
        $query = $query->getQuery();

        $query->wheres = (new Collection($query->wheres))->reject(function ($where) {
            return $this->isScopeConstraint($where);
        })->values()->all();
    }
55604
public function remove(Builder $builder, Model $model)
    {
        $query      = $builder->getQuery();
        $column     = $model->getQualifiedActiveColumn();
        $bindingKey = 0;

        foreach ((array) $query->wheres as $key => $where) {

            if ($this->isActiveConstraint($where, $column)) {

                $this->removeWhere($query, $key);
                $this->removeBinding($query, $bindingKey);
            }

            if ( ! in_array($where['type'], ['Null', 'NotNull'])) {
                $bindingKey++;
            }
        }
    }
773196
protected function doApply(Builder $builder, $field, $mode = Constraint::MODE_AND)
    {
        if ($this->operator == Constraint::OPERATOR_IN) {
            $method = $mode != static::MODE_OR ? 'whereIn' : 'orWhereIn';
            $builder->$method($field, $this->value);
        } elseif ($this->operator == Constraint::OPERATOR_NOT_IN) {
            $method = $mode != static::MODE_OR ? 'whereNotIn' : 'orWhereNotIn';
            $builder->$method($field, $this->value);
        } elseif ($this->operator == Constraint::OPERATOR_NOT_NULL) {
            $method = $mode != static::MODE_OR ? 'whereNotNull' : 'orWhereNotNull';
            $builder->$method($field);
        } elseif ($this->operator == Constraint::OPERATOR_NULL) {
            $method = $mode != static::MODE_OR ? 'whereNull' : 'orWhereNull';
            $builder->$method($field);
        } else {
            $method = $mode != static::MODE_OR ? 'where' : 'orWhere';
            $builder->$method($field, $this->operator, $this->value);
        }
    }
260548
protected function isQueryBuilder($model): bool
    {
        return $model instanceof \Illuminate\Database\Query\Builder
                    || $model instanceof \Illuminate\Database\Eloquent\Builder;
    }
1130441
def remove_builder(cls, builder_name: str):
        
        cls.builders.pop(builder_name, None)
        for hook_spec in cls.hooks.values():
            hook_spec.pop(builder_name, None)
1353995
public function remove(Builder $builder, Model $model)
    {
        $query      = $builder->getQuery();
        $columns    = $model->getQualifiedOrderByColumns();

        foreach ($columns as $column => $direction) {

            foreach ((array) $query->orders as $key => $order) {

                if ($order['column'] == $column) {
                    $this->removeOrderBy($query, $key);
                }
            }
        }
    }
1120169
public function apply(Builder $builder, Model $model): void
    {
        if (method_exists($model, 'shouldApplyEndedAtScope') && $model->shouldApplyEndedAtScope()) {
            $builder->whereNull('ended_at');
        }
    }
750169
def delete_for_obj(self, entity_model_obj):
        
        return self.filter(
            entity_type=ContentType.objects.get_for_model(
                entity_model_obj, for_concrete_model=False), entity_id=entity_model_obj.id).delete(
            force=True)
688148
protected function listifyScopedQuery()
    {
        $model = new static;

        $model->setListifyConfig('scope', $this->listifyScopeCondition());

        // if set, call a method that may be used to remove global scopes
        // and other automatically active listify-scope breaking clauses
        if (method_exists($this, 'cleanListifyScopedQuery')) {
            $model = $this->cleanListifyScopedQuery($model);
        }

        return $model->whereRaw($this->listifyScopeCondition());
    }
249697
protected function createDeleteModelBuilder(): ModelQueryBuilder
    {
        $builder = $this
            ->createBuilder($this->getModelClass())
            ->deleteModels();

        $this->applyTableFilters($builder);

        $result = $this->builderOnDelete($builder);

        $this->clearBuilderParameters();

        return $result;
    }
118555
public function applyScopes()
    {
        if (! $this->scopes) {
            return $this;
        }

        $builder = $this;

        foreach ($builder->scopes as $identifier => $scope) {
            if (! isset($builder->scopes[$identifier])) {
                continue;
            }

            $builder->callScope(function (DynamoDbQueryBuilder $builder) use ($scope) {
                // If the scope is a Closure we will just go ahead and call the scope with the
                // builder instance. The "callScope" method will properly group the clauses
                // that are added to this query so "where" clauses maintain proper logic.
                if ($scope instanceof Closure) {
                    $scope($builder);
                }

                // If the scope is a scope object, we will call the apply method on this scope
                // passing in the builder and the model instance. After we run all of these
                // scopes we will return back the builder instance to the outside caller.
                if ($scope instanceof Scope) {
                    throw new NotSupportedException('Scope object is not yet supported');
                }
            });

            $builder->withoutGlobalScope($identifier);
        }

        return $builder;
    }