Apply the scope to a given Eloquent query builder.

@param  \Illuminate\Database\Eloquent\Builder  $builder
@return void
350916
public function apply(Builder $builder, Model $model) {
    $subclassTypes = array_keys($model->getSingleTableTypeMap());

    if (!empty($subclassTypes) ) {
      $builder->whereIn($model->getQualifiedSingleTableTypeColumn(), $subclassTypes);
    }
  }
1211533
public function apply(Builder $builder, $field, $mode = Constraint::MODE_AND)
    {
        if ($this->isRelation($field)) {
            list($relation, $field) = $this->splitRelationField($field);
            if (static::parseIsNegation($relation)) {
                $builder->whereDoesntHave($relation, function (Builder $builder) use ($field, $mode) {
                    $this->doApply($builder, $field, $mode);
                });
            } else {
                $builder->whereHas($relation, function (Builder $builder) use ($field, $mode) {
                    $this->doApply($builder, $field, $mode);
                });
            }
        } else {
            $this->doApply($builder, $field, $mode);
        }
    }
1296751
public function apply(Builder $builder, Model $model): void
    {
        if (method_exists($model, 'shouldApplyVerifiedAtScope') && $model->shouldApplyVerifiedAtScope()) {
            $builder->whereNotNull('verified_at');
        }
    }
427479
private function remapBuilderColumns(Builder $builder): void {
    if($builder->aggregate === null) {
      if($builder->columns === ['*']) {
        $builder->columns = array_keys($this->to_db);
      }

      if(is_string($builder->columns)) {
        $builder->columns = [$builder->columns];
      }

      $this->remapColumns($builder->columns);
    } else {
      if($builder->aggregate['columns'] == ['*']) {
        return;
      }

      $this->remapColumns($builder->aggregate['columns'], false);
    }
  }
1291133
protected function applySearchClauses(Builder $query): void
    {
        if ($searched = $this->getAttribute('request')->search) {
            $this->getAttribute('searchableColumns')
                ->map(function (TableListColumn $column, int $key) use (&$query, $searched) {
                    $table = $column->getAttribute('customColumnTable');
                    $attribute = $column->getAttribute('customColumnTableRealAttribute')
                        ? $column->getAttribute('customColumnTableRealAttribute')
                        : $column->getAttribute('attribute');
                    if ($key > 0) {
                        $query->orWhere($table . '.' . $attribute, 'like', '%' . $searched . '%');
                    } else {
                        $query->where($table . '.' . $attribute, 'like', '%' . $searched . '%');
                    }
                });
        }
    }
1357841
protected function applyCriteria(Builder $builder, array $criteria)
    {
        foreach ($criteria as $criterion) {
            $criterion->apply($builder);
        }
    }
312969
public function scopeOfOwner(Builder $builder, Model $owner): Builder
    {
        return $builder->where('owner_type', $owner->getMorphClass())->where('owner_id', $owner->getKey());
    }
683329
private function remapWheres(Builder $builder): void {
    if($builder->wheres !== null) {
      foreach($builder->wheres as &$where) {
        if(array_key_exists($where['column'], $this->to_db)) {
          $where['column'] = $this->to_db[$where['column']];
        }
      }
    }
  }
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;
    }
180831
protected function addWithoutEnded(Builder $builder): void
    {
        $builder->macro('withoutEnded', function (Builder $builder) {
            return $builder->withoutGlobalScope($this)->where('is_ended', 0);
        });
    }
821728
public function apply(Builder $builder, Model $model)
    {
        if (!UserUtils::hasDisplayAllStatus())
        {
            $builder->where($model->getQualifiedStatusColumn(), true);
        }
        $this->extend($builder);

    }
588027
public function apply(Builder $builder, Model $model)
    {
        $column = $model->getQualifiedPublishedAtColumn();

        $builder->where($column, '=', 1);

        $this->addWithDrafts($builder);
    }
1290502
public function apply(Builder $builder)
    {
        $sortMethod = 'sort' . studly_case($this->getField());

        if(method_exists($builder->getModel(), $sortMethod)) {
            call_user_func_array([$builder->getModel(), $sortMethod], [$builder, $this->getOrder()]);
        } else {
            $builder->orderBy($this->getField(), $this->getOrder());
        }
    }
736411
public function scopeWhereSlug(Builder $scope, string $slug): Builder
    {
        return $scope->where($this->getSlugKeyName(), $slug);
    }
33604
public function apply(Builder $builder, Model $model)
    {
        $column = $model->getQualifiedActiveColumn();

        $builder->where($column, true);

        $this->addWithInactive($builder);
    }
780216
public function registerGlobalScopes($builder)
    {
        foreach ($this->getGlobalScopes() as $identifier => $scope) {
            $builder->withGlobalScope($identifier, $scope);
        }

        return $builder;
    }
459910
def _apply_scope(self, scope, builder):
        
        if callable(scope):
            scope(builder)
        elif isinstance(scope, Scope):
            scope.apply(builder, self.get_model())