Add the `withDrafted` extension to the builder.

@param \Illuminate\Database\Eloquent\Builder $builder
@return void
772469
protected function addWithDrafted(Builder $builder): void
    {
        $builder->macro('withDrafted', function (Builder $builder) {
            return $builder->withoutGlobalScope($this);
        });
    }
802538
protected function addUndoInvite(Builder $builder): void
    {
        $builder->macro('undoInvite', function (Builder $builder) {
            return $builder->update(['is_invited' => 0]);
        });
    }
524348
private function applyOrdering($builder)
    {
        foreach ($this->ordering as $column => $order) {
            $builder->orderBy($column, $order);
        }

        return $builder;
    }
686725
public function apply(Builder $builder)
    {
        $this->builder = $builder;

        if (method_exists($this, $this->orderBy())) {
            call_user_func([$this, $this->orderBy()]);
        }

        return $this->builder;
    }
1259807
protected function addWithAnyStatus(Builder $builder)
    {
        $builder->macro('withAnyStatus', function (Builder $builder) {
            $this->remove($builder, $builder->getModel());
            return $builder;
        });
    }
280939
protected function addApprove(Builder $builder): void
    {
        $builder->macro('approve', function (Builder $builder) {
            $builder->withNotApproved();

            return $builder->update(['approved_at' => Date::now()]);
        });
    }
446854
protected function addWithoutNotInvited(Builder $builder): void
    {
        $builder->macro('withoutNotInvited', function (Builder $builder) {
            return $builder->withoutGlobalScope($this)->whereNotNull('invited_at');
        });
    }
734392
protected function addUndoDraft(Builder $builder): void
    {
        $builder->macro('undoDraft', function (Builder $builder) {
            $builder->withDrafted();

            return $builder->update(['drafted_at' => null]);
        });
    }
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());
        }
    }
193982
protected function addWithPending(Builder $builder)
    {
        $builder->macro('withPending', function (Builder $builder) {
            $this->remove($builder, $builder->getModel());

            return $builder->whereIN($this->getStatusColumn($builder), [Status::APPROVED, Status::PENDING]);
        });
    }
93481
protected function initializeFromBuilder(Builder $builder)
    {
        $this->setModel($builder->getModel())
            ->setEagerLoads($builder->getEagerLoads());

        $builder->macro('getProtected', function (Builder $builder, string $property) {
            return $builder->{$property};
        });

        $this->scopes = $builder->getProtected('scopes');

        $this->localMacros = $builder->getProtected('localMacros');

        $this->onDelete = $builder->getProtected('onDelete');
    }
1365318
protected function addUndoEnd(Builder $builder): void
    {
        $builder->macro('undoEnd', function (Builder $builder) {
            $builder->withEnded();

            return $builder->update(['ended_at' => null]);
        });
    }
588027
public function apply(Builder $builder, Model $model)
    {
        $column = $model->getQualifiedPublishedAtColumn();

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

        $this->addWithDrafts($builder);
    }
543229
protected function addWithNotKept(Builder $builder): void
    {
        $builder->macro('withNotKept', function (Builder $builder) {
            return $builder->withoutGlobalScope($this);
        });
    }
1370651
protected function addWithClosed(Builder $builder): void
    {
        $builder->macro('withClosed', function (Builder $builder) {
            return $builder->withoutGlobalScope($this);
        });
    }
523621
protected function addActivate(Builder $builder): void
    {
        $builder->macro('activate', function (Builder $builder) {
            $builder->withNotActivated();

            return $builder->update(['is_active' => 1]);
        });
    }
341414
protected function addOnlyEnded(Builder $builder): void
    {
        $builder->macro('onlyEnded', function (Builder $builder) {
            return $builder->withoutGlobalScope($this)->whereNotNull('ended_at');
        });
    }