Remove the scope from the given Eloquent query builder.

@param  \Illuminate\Database\Eloquent\Builder $builder
@param  \Illuminate\Database\Eloquent\Model $model
@return void
357686
public function remove(Builder $builder, Model $model)
    {
        $query = $builder->getQuery();

        if (is_null($query->wheres)) {
            return;
        }

        $bindingKey = 0;

        $scopeConstraints = $this->getScopeConstraints($model);

        foreach ((array) $query->wheres as $key => $where) {
            $bindingsCount = $this->countBindings($where);

            if (in_array($where, $scopeConstraints)) {
                $this->removeWhere($query, $key);

                $this->removeBindings($query, $bindingKey, $bindingsCount);
            } else {
                $bindingKey += $bindingsCount;
            }
        }

        $query->wheres = array_values($query->wheres);
    }
981220
public function scopeFiltered(Builder $builder, array $query = [])
    {
        $query = (array)($query ?: Input::all());
        $this->validateFieldNames($query);

        $mode = $this->getQueryMode($query);
        $query = $this->filterNonSearchableParameters($query);
        $constraints = $this->getConstraints($builder, $query);

        $this->applyConstraints($builder, $constraints, $mode);
    }
589200
public function apply(Builder $builder, Model $model)
    {
        $column = $this->getPolicyColumn($model);
        if (is_null($column) && get_class($model) !== \Antares\Model\User::class) {
            return;
        }

        if (!auth()->user()) {
            return;
        }
        $id       = auth()->user()->roles->first()->id;
        $elements = Cache::remember('roles1-' . $id, 5, function() use($id) {
                    $roles = app(Role::class)->withTrashed()->orderby('parent_id')->get()->toArray();
                    return $this->getLowerRoles($roles, $id);
                });

        $uid = user()->id;
        if (get_class($model) === \Antares\Model\User::class) {
            if (empty($elements)) {
                $builder->whereRaw("(tbl_users.id is null or tbl_users.id=?)", [$uid]);
            } else {
                $in = implode(',', array_values($elements));
                $builder->whereRaw("(tbl_users.id is null or tbl_users.id=? or tbl_users.id in (select user_id from tbl_user_role where role_id in({$in})))", [$uid]);
            }
        } elseif (!empty($elements)) {
            $in = implode(',', array_values($elements));
            $builder->whereRaw("(user_id is null or user_id=? or user_id in (select user_id from tbl_user_role where role_id in({$in})))", [$uid]);
        }
    }
576789
public function apply(Builder $builder, Model $model)
    {
        $builder->where(
            $model->getQualifiedApprovalStatusColumn(),
            ApprovalStatuses::APPROVED
        );
    }
471134
public function scopeOfCreator(Builder $builder, Model $user): Builder
    {
        return $builder->where('created_by_type', $user->getMorphClass())->where('created_by_id', $user->getKey());
    }
1129534
public function clearCache(Model $model) {
        if ($this->_cached) {
            foreach ($this->_cached as $key => $value) {
                $this->deleteCache($model, $key);
            }
        }

        return Cache::clear(false, $this->settings[$model->alias]['cacheConfig']);
    }
479166
public function afterDelete(Model &$model)
    {
        /** @var \T4\Orm\Model $class */
        $class = get_class($model);
        $tableName = $class::getTableName();
        /** @var \T4\Dbal\Connection $connection */
        $connection = $class::getDbConnection();

        $query = (new Query())
            ->delete()
            ->table($tableName)
            ->where('__lft>:lft AND __rgt<:rgt')
            ->params([':lft' => $model->__lft, ':rgt' => $model->__rgt]);
        $connection->execute($query);

        $this->removeFromTreeByLftRgt($connection, $tableName, $model->__lft, $model->__rgt);

        $model->__lft = 0;
        $model->__rgt = 0;
        $model->__lvl = 0;
        $model->__prt = 0;
    }
959559
public function remove(Builder $builder, Eloquent $model)
    {
        $query = $builder->getQuery();

        foreach ((array)$query->wheres as $key => $where)
        {
            // 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 this developer to
            // include deleted model in a relationship result set that is lazy loaded.
            if ($this->isPostTypeConstraint($where, 'post_type'))
            {
                unset($query->wheres[$key]);

                $query->wheres = array_values($query->wheres);
            }
        }
    }
1042020
public function scopeOnlyDeletedBy(Builder $query, Model $user)
    {
        return $query->where(config('accountable.column_names.deleted_by'), $user->getKey());
    }
1061312
public function extend(EloquentBuilder $builder)
    {
        $builder->macro('searchable', function (EloquentBuilder $builder, $chunk = null) {
            $builder->chunk($chunk ?: config('scout.chunk.searchable', 500), function ($models) {
                $models->filter->shouldBeSearchable()->searchable();

                event(new ModelsImported($models));
            });
        });

        $builder->macro('unsearchable', function (EloquentBuilder $builder, $chunk = null) {
            $builder->chunk($chunk ?: config('scout.chunk.unsearchable', 500), function ($models) {
                $models->unsearchable();

                event(new ModelsFlushed($models));
            });
        });
    }
358389
public function scopeOnlyCreatedBy(Builder $query, Model $user)
    {
        return $query->where(config('accountable.column_names.created_by'), $user->getKey());
    }
821728
public function apply(Builder $builder, Model $model)
    {
        if (!UserUtils::hasDisplayAllStatus())
        {
            $builder->where($model->getQualifiedStatusColumn(), true);
        }
        $this->extend($builder);

    }
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();
    }
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");
    }
1289328
protected function addWithNotVerified(Builder $builder): void
    {
        $builder->macro('withNotVerified', function (Builder $builder) {
            return $builder->withoutGlobalScope($this);
        });
    }
183767
protected function addWithNotAccepted(Builder $builder): void
    {
        $builder->macro('withNotAccepted', function (Builder $builder) {
            return $builder->withoutGlobalScope($this);
        });
    }
141885
public function search(Builder $builder)
    {
        try {
            return $this->performSearch($builder);
        } catch (IndexNotFoundException $e) {
            $this->initIndex($builder->model);
        }
    }