diff --git a/src/Helpers/CreateMailableHelper.php b/src/Helpers/CreateMailableHelper.php index 8c64026..eaeb382 100644 --- a/src/Helpers/CreateMailableHelper.php +++ b/src/Helpers/CreateMailableHelper.php @@ -14,8 +14,7 @@ public function createMailable($record) "icon" => null, "icon_color" => null, ]; - $emailTemplate = EmailTemplate::findOrFail($record->mountedTableActionRecord); - + $emailTemplate = EmailTemplate::findOrFail($record->id); // preparing class name $className = str_replace('-', ' ', $emailTemplate->key); $className = str_replace(' ', '', ucwords($className)); diff --git a/src/Resources/EmailTemplateResource.php b/src/Resources/EmailTemplateResource.php index e6d1edb..915288a 100644 --- a/src/Resources/EmailTemplateResource.php +++ b/src/Resources/EmailTemplateResource.php @@ -2,23 +2,24 @@ namespace Visualbuilder\EmailTemplates\Resources; -use Filament\Forms\Components\Grid; -use Filament\Forms\Components\Section; -use Filament\Forms\Components\Select; -use Filament\Forms\Components\TextInput; -use Filament\Forms\Form; +use Filament\Tables; use Filament\Forms\Set; +use Filament\Forms\Form; +use Filament\Tables\Table; +use Illuminate\Support\Str; use Filament\Resources\Resource; -use Filament\Tables; +use Filament\Forms\Components\Grid; use Filament\Tables\Actions\Action; -use Filament\Tables\Columns\TextColumn; -use Filament\Tables\Table; +use Filament\Forms\Components\Select; +use Filament\Forms\Components\Section; use FilamentTiptapEditor\TiptapEditor; +use Filament\Tables\Columns\TextColumn; +use Filament\Forms\Components\TextInput; +use Filament\Notifications\Notification; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\SoftDeletingScope; -use Illuminate\Support\Str; -use Visualbuilder\EmailTemplates\Components\SelectLanguage; use Visualbuilder\EmailTemplates\Models\EmailTemplate; +use Visualbuilder\EmailTemplates\Components\SelectLanguage; use Visualbuilder\EmailTemplates\Resources\EmailTemplateResource\Pages; class EmailTemplateResource extends Resource @@ -215,7 +216,17 @@ public static function table(Table $table): Table Action::make('create-mail-class') ->label("Create Mail Class") ->icon('heroicon-o-document-text') - ->action('createMailClass'), + // ->action('createMailClass'), + ->action(function ($record) { + $createMailableHelper = app(\Visualbuilder\EmailTemplates\Contracts\CreateMailableInterface::class); + $notify = $createMailableHelper->createMailable($record); + // dd($record); + Notification::make() + ->title($notify->title) + ->icon($notify->icon) + ->iconColor($notify->icon_color) + ->send(); + }), Tables\Actions\ViewAction::make() ->label("Preview") ->hidden(fn ($record) => $record->trashed()), diff --git a/src/Resources/EmailTemplateResource/Pages/ListEmailTemplates.php b/src/Resources/EmailTemplateResource/Pages/ListEmailTemplates.php index 38eed99..6c767ac 100644 --- a/src/Resources/EmailTemplateResource/Pages/ListEmailTemplates.php +++ b/src/Resources/EmailTemplateResource/Pages/ListEmailTemplates.php @@ -18,15 +18,4 @@ protected function getActions(): array Actions\CreateAction::make(), ]; } - - public function createMailClass(): void - { - $this->createMailableHelper = app(\Visualbuilder\EmailTemplates\Contracts\CreateMailableInterface::class); - $notify = $this->createMailableHelper->createMailable($this); - Notification::make() - ->title($notify->title) - ->icon($notify->icon) - ->iconColor($notify->icon_color) - ->send(); - } }