From 33ce28a152a3c6800191b4233dcea1e446e40eac Mon Sep 17 00:00:00 2001 From: Fady Mondy Date: Mon, 18 Nov 2024 16:24:20 +0200 Subject: [PATCH] fix lang problem --- src/Filament/Resources/TypeResource.php | 6 ++++++ .../Resources/TypeResource/Pages/ListTypes.php | 5 ----- src/FilamentTypesPlugin.php | 17 ++++++++++------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Filament/Resources/TypeResource.php b/src/Filament/Resources/TypeResource.php index 66c831f..82fddaa 100644 --- a/src/Filament/Resources/TypeResource.php +++ b/src/Filament/Resources/TypeResource.php @@ -18,6 +18,12 @@ class TypeResource extends Resource protected static ?string $navigationIcon = 'heroicon-o-tag'; + + public static function getTranslatableLocales(): array + { + return filament('filament-types')->getLocals(); + } + public static function getNavigationLabel(): string { return trans('filament-types::messages.title'); diff --git a/src/Filament/Resources/TypeResource/Pages/ListTypes.php b/src/Filament/Resources/TypeResource/Pages/ListTypes.php index 0409aeb..c40f001 100644 --- a/src/Filament/Resources/TypeResource/Pages/ListTypes.php +++ b/src/Filament/Resources/TypeResource/Pages/ListTypes.php @@ -18,11 +18,6 @@ public function getTitle(): string protected static string $resource = TypeResource::class; - public static function getTranslatableLocales(): array - { - return ['en', 'ar']; - } - protected function getHeaderActions(): array { return TypeResource\Actions\ManagePageActions::make($this); diff --git a/src/FilamentTypesPlugin.php b/src/FilamentTypesPlugin.php index 635a2ba..94f8982 100644 --- a/src/FilamentTypesPlugin.php +++ b/src/FilamentTypesPlugin.php @@ -50,13 +50,16 @@ public function getId(): string public function register(Panel $panel): void { - $panel->plugin( - SpatieLaravelTranslatablePlugin::make() - ->defaultLocales($this->getLocals()), - ) - ->resources([ - TypeResource::class, - ]); + if(!$panel->hasPlugin('spatie-laravel-translatable')) { + $panel->plugin( + SpatieLaravelTranslatablePlugin::make() + ->defaultLocales($this->getLocals()), + ); + } + + $panel->resources([ + TypeResource::class, + ]); } public function boot(Panel $panel): void