From 4f5f1ad74aab1e598f3e71aa55896b5cc0597b9b Mon Sep 17 00:00:00 2001 From: Schilly Date: Sun, 8 Dec 2024 11:24:49 -0500 Subject: [PATCH 1/3] Fixed "locals" config option. --- config/filament-types.php | 16 ++++++---------- src/FilamentTypesPlugin.php | 8 +++----- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/config/filament-types.php b/config/filament-types.php index 578d8ff..445f860 100644 --- a/config/filament-types.php +++ b/config/filament-types.php @@ -36,15 +36,11 @@ * Locals * * If you need to use locals for the types you can set it here + * + * EG: ['en','ar'] will provide English and Arabic options. + * + * Default: NULL, provides English and Arabic options. */ - 'locals' => [ - 'ar' => [ - 'ar' => 'العربية', - 'en' => 'Arabic', - ], - 'en' => [ - 'ar' => 'الإنجليزية', - 'en' => 'English', - ], - ], + + 'locals' => NULL, ]; diff --git a/src/FilamentTypesPlugin.php b/src/FilamentTypesPlugin.php index 5699286..8d516ef 100644 --- a/src/FilamentTypesPlugin.php +++ b/src/FilamentTypesPlugin.php @@ -16,16 +16,14 @@ class FilamentTypesPlugin implements Plugin /** * @return $this */ - public function locals(array $locals): self + public function locals() { - self::$locals = $locals; - - return $this; + return (!is_null(config('filament-types.locals'))) ? config('filament-types.locals') : $this->locals; } public function getLocals(): array { - return self::$locals; + return $this->locals(); } /** From b8bc7a69bbe3969933a66677549a652c76712b22 Mon Sep 17 00:00:00 2001 From: Schilly Date: Sun, 8 Dec 2024 11:31:13 -0500 Subject: [PATCH 2/3] Docs update for new locals functions --- README.md | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5c872b2..a2e8cc4 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,17 @@ FilamentTypes::register([ ]); ``` +## Config Locales + +You can change the locals within the `filament-types` config. + +- Publish the config file/ +- Modify the `locals` array to include the two character language code that applys to the language you wish to offer. EG: + +``` +'locals' = ['en'], +``` + ## Use Type Helper you can find any type with the helper method to use it anywhere @@ -112,7 +123,7 @@ TypeColumn::make('type') ->searchable(), ``` -## Auto Caching +## Auto Caching on your `.env` add this @@ -181,7 +192,7 @@ class NotesGroups extends BaseTypePage } ``` -it will be not appear on the navigation menu by default but you can change that by just use this method +it will be not appear on the navigation menu by default but you can change that by just use this method ```php public static function shouldRegisterNavigation(): bool @@ -195,7 +206,7 @@ public static function shouldRegisterNavigation(): bool if you like to use a type as a package we create a blade component for you to make it easy to use anywhere on your app like this ```html - + ``` ## User Types Resource Hooks @@ -277,7 +288,7 @@ public function boot() ManagePageActions::register([ Filament\Actions\Action::make('action') ]); - + } ``` @@ -331,7 +342,6 @@ if you like to check the code by `PHPStan` just use this command composer analyse ``` - ## Other Filament Packages Checkout our [Awesome TomatoPHP](https://github.com/tomatophp/awesome) From b20b2404c02bbddabef8f22dba9678db987f01ae Mon Sep 17 00:00:00 2001 From: Schilly Date: Sun, 8 Dec 2024 13:04:07 -0500 Subject: [PATCH 3/3] bugfix --- src/FilamentTypesPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FilamentTypesPlugin.php b/src/FilamentTypesPlugin.php index 8d516ef..b098ecb 100644 --- a/src/FilamentTypesPlugin.php +++ b/src/FilamentTypesPlugin.php @@ -9,7 +9,7 @@ class FilamentTypesPlugin implements Plugin { - protected static array $locals = ['ar', 'en']; + protected array $locals = ['ar', 'en']; protected static array $types = [];