diff --git a/README.md b/README.md index 5eb9333..cc3c5ae 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,14 @@ Run the install command php artisan filament-email-templates:install ``` +## Publish EmailTemplateResource + +You can publish EmailTemplateResource to your project. Run the command given below then go to `config/email-templates.php` and set `publish_resource` to `true` + +```bash + php artisan email-template:publish +``` + ## Usage ### HTML Editor diff --git a/config/email-templates.php b/config/email-templates.php index 5420b68..b6a3902 100644 --- a/config/email-templates.php +++ b/config/email-templates.php @@ -4,6 +4,10 @@ //If you wish to customise the table name change this before migration 'table_name' => 'vb_email_templates', + //If you want to use your own resource for email templates, + //you can set this to true and use `php artisan email-template:publish` to publish the resource + "publish_resource" => false, + //Email templates will be copied to resources/views/vendor/vb-email-templates/email //default.blade.php is base view that can be customised below 'default_view' => 'default', diff --git a/src/EmailTemplatesServiceProvider.php b/src/EmailTemplatesServiceProvider.php index 9fc9945..c21cc08 100644 --- a/src/EmailTemplatesServiceProvider.php +++ b/src/EmailTemplatesServiceProvider.php @@ -16,14 +16,24 @@ class EmailTemplatesServiceProvider extends PluginServiceProvider { - protected array $resources = [ - EmailTemplateResource::class, - ]; + protected array $resources = []; protected array $styles = [ 'vb-email-templates-styles' => 'https://cdn.jsdelivr.net/gh/lipis/flag-icons@6.6.6/css/flag-icons.min.css', ]; + public function __construct($app) + { + parent::__construct($app); + + //Check if customer publish the resource convert it to self register resource + if(!config('email-templates.publish_resource')) { + $this->resources = [ + EmailTemplateResource::class, + ]; + } + } + public function configurePackage(Package $package): void { $package->name("filament-email-templates") diff --git a/src/Stubs/CreateEmailTemplate.stub b/src/Stubs/CreateEmailTemplate.stub index dc5c257..c1d38ea 100644 --- a/src/Stubs/CreateEmailTemplate.stub +++ b/src/Stubs/CreateEmailTemplate.stub @@ -1,9 +1,9 @@