src/TranslatableScope.php
public function extend(EloquentBuilder $builder)
    {
        $builder->macro('onlyTranslated', function (EloquentBuilder $builder, $locale = null) {
            $builder->getModel()->setOnlyTranslated(true);

            if($locale) {
                $builder->getModel()->setLocale($locale);
            }

            return $builder;
        });

        $builder->macro('withUntranslated', function (EloquentBuilder $builder) {
            $builder->getModel()->setOnlyTranslated(false);

            return $builder;
        });

        $builder->macro('withFallback', function (EloquentBuilder $builder, $fallbackLocale = null) {
            $builder->getModel()->setWithFallback(true);

            if($fallbackLocale) {
                $builder->getModel()->setFallbackLocale($fallbackLocale);
            }

            return $builder;
        });

        $builder->macro('withoutFallback', function (EloquentBuilder $builder) {
            $builder->getModel()->setWithFallback(false);

            return $builder;
        });

        $builder->macro('translateInto', function (EloquentBuilder $builder, $locale) {
            if($locale) {
                $builder->getModel()->setLocale($locale);
            }

            return $builder;
        });

        $builder->macro('withoutTranslations', function (EloquentBuilder $builder) {
            $builder->withoutGlobalScope(static::class);

            return $builder;
        });

        $builder->macro('withAllTranslations', function (EloquentBuilder $builder) {
            $builder->withoutGlobalScope(static::class)
                ->with('translations');

            return $builder;
        });
    }
public function extend(EloquentBuilder $builder)
    {
        $builder->macro('onlyTranslated', function (EloquentBuilder $builder, $locale = null) {
            $builder->getModel()->setOnlyTranslated(true);

            if($locale) {
                $builder->getModel()->setLocale($locale);
            }

            return $builder;
        });

        $builder->macro('withUntranslated', function (EloquentBuilder $builder) {
            $builder->getModel()->setOnlyTranslated(false);

            return $builder;
        });

        $builder->macro('withFallback', function (EloquentBuilder $builder, $fallbackLocale = null) {
            $builder->getModel()->setWithFallback(true);

            if($fallbackLocale) {
                $builder->getModel()->setFallbackLocale($fallbackLocale);
            }

            return $builder;
        });

        $builder->macro('withoutFallback', function (EloquentBuilder $builder) {
            $builder->getModel()->setWithFallback(false);

            return $builder;
        });

        $builder->macro('translateInto', function (EloquentBuilder $builder, $locale) {
            if($locale) {
                $builder->getModel()->setLocale($locale);
            }

            return $builder;
        });

        $builder->macro('withoutTranslations', function (EloquentBuilder $builder) {
            $builder->withoutGlobalScope(static::class);

            return $builder;
        });

        $builder->macro('withAllTranslations', function (EloquentBuilder $builder) {
            $builder->withoutGlobalScope(static::class)
                ->with('translations');

            return $builder;
        });
    }
Extend the builder.
@param Builder $builder