Skip to content

Commit

Permalink
Merge pull request #13 from pschilly/master
Browse files Browse the repository at this point in the history
Fix `locals` config option
  • Loading branch information
3x1io authored Dec 14, 2024
2 parents 0a283a6 + b20b240 commit 5c3511c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -112,7 +123,7 @@ TypeColumn::make('type')
->searchable(),
```

## Auto Caching
## Auto Caching

on your `.env` add this

Expand Down Expand Up @@ -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
Expand All @@ -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
<x-tomato-type :type="$type" label="Group"/>
<x-tomato-type :type="$type" label="Group" />
```

## User Types Resource Hooks
Expand Down Expand Up @@ -277,7 +288,7 @@ public function boot()
ManagePageActions::register([
Filament\Actions\Action::make('action')
]);

}
```

Expand Down Expand Up @@ -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)
16 changes: 6 additions & 10 deletions config/filament-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
];
10 changes: 4 additions & 6 deletions src/FilamentTypesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@

class FilamentTypesPlugin implements Plugin
{
protected static array $locals = ['ar', 'en'];
protected array $locals = ['ar', 'en'];

protected static array $types = [];

/**
* @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();
}

/**
Expand Down

0 comments on commit 5c3511c

Please sign in to comment.