Pending scope

@param Builder $query
@return Builder
971068
public function scopePending(Builder $query)
    {
        return $query->where('status', Node::PENDING)
            ->where('published_at', '>', Carbon::now());
    }
1067401
public function scopeSearch(Builder $query, $name, $userId)
    {
        return $query->where('user_id', '=', $userId)->where('name', '=', $name);
    }
1176599
public function scopeWhereDislikedBy(Builder $query, $userId = null)
    {
        return app(LikeableServiceContract::class)
            ->scopeWhereLikedBy($query, LikeType::DISLIKE, $userId);
    }
146143
public function scopeUseless($query)
    {
        return $query
            ->where(function ($q) {
                $this->scopeExpired($q);
            })
            ->orWhere(function ($q) {
                $this->scopeFull($q);
            });
    }
31204
public function scopeWithTranslation(Builder $query)
    {
        $query->with([
            'translations' => function (Relation $query) {
                if ($this->useFallback()) {
                    $locale = $this->locale();
                    $countryFallbackLocale = $this->getFallbackLocale($locale); // e.g. de-DE => de
                    $locales = array_unique([$locale, $countryFallbackLocale, $this->getFallbackLocale()]);

                    return $query->whereIn($this->getTranslationsTable().'.'.$this->getLocaleKey(), $locales);
                }

                return $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), $this->locale());
            },
        ]);
    }
1344002
public function setQuery(\Illuminate\Database\Eloquent\Builder &$query): PaginationInterface
    {
        $this->_query = $query;

        return $this;
    }
428991
public function scopeFiltersApply(Builder $query, $entity = null): Builder
    {
        if (! is_null($entity)) {
            try {
                $this->getEntity($entity);
            } catch (EntityTypeException $e) {
            }
        }

        return $this->filter($query);
    }
1175587
public function scopeSearch(Builder $query, array $search = [])
    {
        if (empty($search)) {
            return $query;
        }

        if (!array_intersect(array_keys($search), $this->searchable)) {
            return $query;
        }

        return $query->where($search);
    }
289314
protected function exportableQuery(Builder $query): Builder
    {
        // Allow executing custom exportable query.
        if (method_exists($this->module, 'exportableQuery')) {
            return $this->module->exportableQuery($query);
        }

        return $query
            ->when($query->getModel() instanceof Translatable, function ($query) {
                $query->translated();
            })
            // leave select after joining with translations
            // table in order to rewrite selected columns
            ->select($this->exportableColumns());
    }
789061
public function scopeFutureSchedules($query)
    {
        return $query->whereIn('status', [self::UPCOMING, self::IN_PROGRESS])->where('scheduled_at', '>=', Carbon::now());
    }
737348
public function scopeFiltersApplySelection(Builder $query, $selection)
    {
        if (! is_object($selection)) {
            $selection = app()->make($selection);
        }

        $filters = $selection->filters();

        return $this->scopeFiltersApply($query, $filters);
    }
291796
public function scopeOlderThanOrBetween(Builder $query, $until = null, $from = null)
    {
        if (is_null($until))
        {
            $until = Carbon::now();
        }

        $query->where('created_at', '<', $until);

        if ( ! is_null($from))
        {
            $query->where('created_at', '>=', $from);
        }

        return $query;
    }
398739
public function scopeAdministrators(Builder $query)
    {
        $query->with('roles')->whereNotNull('tbl_users.id')->whereHas('roles', function ($query) {
            $query->whereNotIn('tbl_roles.name', ['member', 'guest', 'client']);
        });


        return $query;
    }
1044319
public function scopeWithTranslations(Builder $query, string $locale = null): Builder
    {
        $locale = $locale ?: $this->getLocale();

        return $query->with(['translations' => function (HasMany $query) use ($locale) {
            $query->where('locale', $locale);
        }]);
    }
593050
public function scopeWithType(Builder $query, $type)
    {
        // We do this for querying, searching and sorting with source attributes
        $this->setNodeTypeName($type);

        return $this->scopeWhereTranslation($query, 'source_type', $type, null);
    }
115319
protected function search(Builder $query)
    {
        $q = request('q');

        if (!$q || strlen($q) < $this->minimumSearchInputLength)
            return $query;

        return $this->searchQuery($query, $q);
    }
309366
protected function replayMacros(Builder $query)
    {
        foreach ($this->macroBuffer as $macro) {
            $query->{$macro['method']}(...$macro['parameters']);
        }

        return $query;
    }