isProduction()); TranslatableTabs::configureUsing(function (TranslatableTabs $component) { $component ->localesLabels(baseLocales()) ->locales(array_keys(baseLocales())); }); /** * Order by translation for spatie/laravel-translatable * * @param string $field * @param string $order * @param string $locale * @return \Illuminate\Database\Eloquent\Builder */ Builder::macro('orderByTranslation', function (string $field, string $order = 'asc', ?string $locale = null) { if ( in_array(HasTranslations::class, class_uses($this->model)) && in_array($field, $this->model->translatable) && config('database.default') === 'pgsql' ) { $locale = $locale ?? app()->getLocale(); $this->query->orderByRaw("$field->>'$locale' $order"); } else { $this->query->orderBy($field, $order); } return $this; }); } }