Skip to content

Commit

Permalink
Create mail class functionality not working --fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaybokaderanium committed Aug 18, 2023
1 parent e5dfb78 commit 30955b7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
3 changes: 1 addition & 2 deletions src/Helpers/CreateMailableHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
33 changes: 22 additions & 11 deletions src/Resources/EmailTemplateResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()),
Expand Down
11 changes: 0 additions & 11 deletions src/Resources/EmailTemplateResource/Pages/ListEmailTemplates.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 30955b7

Please sign in to comment.