Skip to content

Commit

Permalink
Merge pull request #17 from abdosaeedelhassan/3.x
Browse files Browse the repository at this point in the history
Change template key to be selectable list from config file
  • Loading branch information
cannycookie authored Sep 22, 2024
2 parents 7a81537 + 49e304a commit c96bc2d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
4 changes: 4 additions & 0 deletions resources/lang/ar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Email Templates": "قوالب البريد الإلكتروني",
"Email Template Themes": "ثيمات قالب البريد الإلكتروني"
}
4 changes: 4 additions & 0 deletions src/EmailTemplatesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function configurePackage(Package $package): void
->hasMigrations(['create_email_templates_themes_table','create_email_templates_table'])
->hasConfigFile(['filament-email-templates', 'filament-tiptap-editor'])
->hasAssets()
->hasTranslations()
->hasViews('vb-email-templates')
->runsMigrations()
->hasCommands([
Expand All @@ -32,6 +33,9 @@ public function packageRegistered(): void
{
parent::packageRegistered();

$this->loadJsonTranslationsFrom(__DIR__.'/../resources/lang/');


$this->app->singleton(CreateMailableInterface::class, CreateMailableHelper::class);
$this->app->singleton(FormHelperInterface::class, FormHelper::class);
$this->app->register(EmailTemplatesEventServiceProvider::class);
Expand Down
11 changes: 5 additions & 6 deletions src/Resources/EmailTemplateResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public static function getNavigationSort(): ?int

public static function getModelLabel(): string
{
return config('filament-email-templates.navigation.templates.label');
return __(config('filament-email-templates.navigation.templates.label'));
}

public static function getPluralModelLabel(): string
{
return config('filament-email-templates.navigation.templates.label');
return __(config('filament-email-templates.navigation.templates.label'));
}

public static function getCluster(): string
Expand Down Expand Up @@ -94,10 +94,9 @@ public static function form(Form $form): Form
Grid::make(['default' => 1, 'sm' => 1, 'md' => 2])
->schema(
[
TextInput::make('key')
->afterStateUpdated(
fn (Set $set, ?string $state) => $set('key', Str::slug($state))
)
Select::make('key')
->options(config('filament-email-templates.template_keys'))
->searchable()
->label(__('vb-email-templates::email-templates.form-fields-labels.key'))
->hint(__('vb-email-templates::email-templates.form-fields-labels.key-hint'))
->required()
Expand Down
4 changes: 2 additions & 2 deletions src/Resources/EmailTemplateThemeResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public static function getNavigationSort(): ?int

public static function getModelLabel(): string
{
return config('filament-email-templates.navigation.themes.label');
return __(config('filament-email-templates.navigation.themes.label'));
}

public static function getPluralModelLabel(): string
{
return config('filament-email-templates.navigation.themes.label');
return __(config('filament-email-templates.navigation.themes.label'));
}

public static function getCluster(): string
Expand Down

0 comments on commit c96bc2d

Please sign in to comment.