Skip to content

Commit

Permalink
email template resource publish functionality path fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaybokaderanium committed Aug 23, 2023
1 parent 5eee26a commit ff8f04e
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 13 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions config/email-templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
16 changes: 13 additions & 3 deletions src/EmailTemplatesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions src/Stubs/CreateEmailTemplate.stub
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace Visualbuilder\EmailTemplates\Resources\EmailTemplateResource\Pages;
namespace App\Filament\Resources\EmailTemplateResource\Pages;

use Filament\Resources\Pages\CreateRecord;
use Visualbuilder\EmailTemplates\Resources\EmailTemplateResource;
use App\Filament\Resources\EmailTemplateResource;

class CreateEmailTemplate extends CreateRecord
{
Expand Down
4 changes: 2 additions & 2 deletions src/Stubs/EditEmailTemplate.stub
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Visualbuilder\EmailTemplates\Resources\EmailTemplateResource\Pages;
namespace App\Filament\Resources\EmailTemplateResource\Pages;

use Filament\Pages\Actions;
use Filament\Resources\Pages\EditRecord;
use Visualbuilder\EmailTemplates\Resources\EmailTemplateResource;
use App\Filament\Resources\EmailTemplateResource;

class EditEmailTemplate extends EditRecord
{
Expand Down
4 changes: 2 additions & 2 deletions src/Stubs/EmailTemplateResource.stub
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Visualbuilder\EmailTemplates\Resources;
namespace App\Filament\Resources;

use Closure;
use Filament\Forms\Components\Card;
Expand All @@ -19,7 +19,7 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\Str;
use Visualbuilder\EmailTemplates\Components\SelectLanguage;
use Visualbuilder\EmailTemplates\Models\EmailTemplate;
use Visualbuilder\EmailTemplates\Resources\EmailTemplateResource\Pages;
use App\Filament\Resources\EmailTemplateResource\Pages;

class EmailTemplateResource extends Resource
{
Expand Down
4 changes: 2 additions & 2 deletions src/Stubs/ListEmailTemplates.stub
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Visualbuilder\EmailTemplates\Resources\EmailTemplateResource\Pages;
namespace App\Filament\Resources\EmailTemplateResource\Pages;

use Filament\Notifications\Notification;
use Filament\Pages\Actions;
use Filament\Resources\Pages\ListRecords;
use Visualbuilder\EmailTemplates\Resources\EmailTemplateResource;
use App\Filament\Resources\EmailTemplateResource;

class ListEmailTemplates extends ListRecords
{
Expand Down
4 changes: 2 additions & 2 deletions src/Stubs/PreviewEmailTemplate.stub
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Visualbuilder\EmailTemplates\Resources\EmailTemplateResource\Pages;
namespace App\Filament\Resources\EmailTemplateResource\Pages;

use Filament\Forms\Components\Card;
use Filament\Forms\Components\Grid;
Expand All @@ -11,7 +11,7 @@ use Filament\Resources\Form;
use Filament\Resources\Pages\ViewRecord;
use Visualbuilder\EmailTemplates\Components\Iframe;
use Visualbuilder\EmailTemplates\Models\EmailTemplate;
use Visualbuilder\EmailTemplates\Resources\EmailTemplateResource;
use App\Filament\Resources\EmailTemplateResource;

class PreviewEmailTemplate extends ViewRecord
{
Expand Down

0 comments on commit ff8f04e

Please sign in to comment.