stan errors
This commit is contained in:
@@ -13,7 +13,6 @@ use Filament\Forms\Components\Hidden;
|
|||||||
use Filament\Forms\Components\RichEditor;
|
use Filament\Forms\Components\RichEditor;
|
||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Components\Textarea;
|
|
||||||
use Filament\Forms\Components\Toggle;
|
use Filament\Forms\Components\Toggle;
|
||||||
use Filament\Schemas\Components\Fieldset;
|
use Filament\Schemas\Components\Fieldset;
|
||||||
use Filament\Schemas\Components\FusedGroup;
|
use Filament\Schemas\Components\FusedGroup;
|
||||||
|
|||||||
@@ -42,18 +42,21 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
* @return \Illuminate\Database\Eloquent\Builder
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
*/
|
*/
|
||||||
Builder::macro('orderByTranslation', function (string $field, string $order = 'asc', ?string $locale = null) {
|
Builder::macro('orderByTranslation', function (string $field, string $order = 'asc', ?string $locale = null) {
|
||||||
|
/** @var \Illuminate\Database\Eloquent\Builder */
|
||||||
|
$builder = $this; // @phpstan-ignore-line
|
||||||
|
|
||||||
if (
|
if (
|
||||||
in_array(HasTranslations::class, class_uses($this->model))
|
in_array(HasTranslations::class, class_uses($builder->model)) // @phpstan-ignore-line
|
||||||
&& in_array($field, $this->model->translatable)
|
&& in_array($field, $builder->model->translatable)
|
||||||
&& config('database.default') === 'pgsql'
|
&& config('database.default') === 'pgsql'
|
||||||
) {
|
) {
|
||||||
$locale = $locale ?? app()->getLocale();
|
$locale = $locale ?? app()->getLocale();
|
||||||
$this->query->orderByRaw("$field->>'$locale' $order");
|
$builder->query->orderByRaw("$field->>'$locale' $order");
|
||||||
} else {
|
} else {
|
||||||
$this->query->orderBy($field, $order);
|
$builder->query->orderBy($field, $order);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $builder;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user