Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ates into hotfix

# Conflicts:
#	src/Resources/EmailTemplateResource/Pages/ViewEmailTemplate.php
  • Loading branch information
cannycookie committed Sep 10, 2023
2 parents 3ada7c7 + c55d214 commit 5a0e99b
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 35 deletions.
20 changes: 10 additions & 10 deletions src/Models/EmailTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class EmailTemplate extends Model
'deleted_at' => 'datetime:Y-m-d H:i:s',
'created_at' => 'datetime:Y-m-d H:i:s',
'updated_at' => 'datetime:Y-m-d H:i:s',
'from' => 'array'
'from' => 'array',
];
/**
* @var string[]
Expand Down Expand Up @@ -162,12 +162,12 @@ public function getEmailPreviewData()
$model = self::createEmailPreviewData();

return [
'user' => $model->user,
'content' => $this->replaceTokens($this->content, $model),
'subject' => $this->replaceTokens($this->subject, $model),
'user' => $model->user,
'content' => $this->replaceTokens($this->content, $model),
'subject' => $this->replaceTokens($this->subject, $model),
'preHeaderText' => $this->replaceTokens($this->preheader, $model),
'title' => $this->replaceTokens($this->title, $model),
'theme' => $this->theme->colours,
'title' => $this->replaceTokens($this->title, $model),
'theme' => $this->theme->colours,
];
}

Expand Down Expand Up @@ -205,8 +205,8 @@ public function scopeLanguage(Builder $query, $language)

return $query->whereIn('language', $languages)
->orderByRaw(
"(CASE WHEN language = ? THEN 1 ELSE 2 END)",
[$language]
"(CASE WHEN language = ? THEN 1 ELSE 2 END)",
[$language]
);
}

Expand All @@ -216,7 +216,7 @@ public function scopeLanguage(Builder $query, $language)
public function viewPath(): Attribute
{
return new Attribute(
get: fn() => config('filament-email-templates.template_view_path').'.'.$this->view
get: fn () => config('filament-email-templates.template_view_path').'.'.$this->view
);
}

Expand All @@ -241,7 +241,7 @@ public function getMailableClass()
$directory = str_replace('/', '\\', config('filament-email-templates.mailable_directory', 'Mail/Visualbuilder/EmailTemplates')); // Convert slashes to namespace format
$fullClassName = "\\App\\{$directory}\\{$className}";

if (!class_exists($fullClassName)) {
if (! class_exists($fullClassName)) {
throw new \Exception("Mailable class {$fullClassName} does not exist.");
}

Expand Down
12 changes: 6 additions & 6 deletions src/Resources/EmailTemplateResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
use Visualbuilder\EmailTemplates\Contracts\CreateMailableInterface;
use Visualbuilder\EmailTemplates\Contracts\FormHelperInterface;
use Visualbuilder\EmailTemplates\Models\EmailTemplate;
use Visualbuilder\EmailTemplates\Models\EmailTemplateTheme;
use Visualbuilder\EmailTemplates\Resources\EmailTemplateResource\Pages;

class EmailTemplateResource extends Resource
Expand Down Expand Up @@ -98,11 +97,12 @@ public static function form(Form $form): Form
TextInput::make('from.name')->default(config('mail.from.address'))
->label(__('vb-email-templates::email-templates.form-fields-labels.email-from-name'))
->required()
->string()
]),
->string(),
]
),
Grid::make(['default' => 3, 'sm' => 1, 'md' => 3])
->schema(
[
[
Select::make('view')
->label(__('vb-email-templates::email-templates.form-fields-labels.template-view'))
->options($templates)
Expand All @@ -118,9 +118,9 @@ public static function form(Form $form): Form
Select::make(config('filament-email-templates.theme_table_name') . '_id')
->label(__('vb-email-templates::email-templates.form-fields-labels.theme'))
->relationship(name: 'theme', titleAttribute: 'name')
->searchable()
->searchable(),
]
),
),

Grid::make(['default' => 1])
->schema(
Expand Down
15 changes: 0 additions & 15 deletions src/Resources/EmailTemplateResource/Pages/ViewEmailTemplate.php

This file was deleted.

2 changes: 1 addition & 1 deletion src/Traits/BuildGenericEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function build()
'theme' => $template->theme->colours,
];

return $this->from($template->from['email'],$template->from['name'])
return $this->from($template->from['email'], $template->from['name'])
->view($template->view_path)
->subject($template->replaceTokens($template->subject, $this))
->to($this->sendTo)
Expand Down
2 changes: 1 addition & 1 deletion tests/factories/EmailTemplateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function definition()
'cc' => null,
'bcc' => null,
'send_to' => 'user',
'from' => ['email'=>$this->faker->email,'name'=>$this->faker->name],
'from' => ['email' => $this->faker->email,'name' => $this->faker->name],
'name' => $this->faker->name,
'preheader' => $this->faker->sentence,
'subject' => $this->faker->sentence,
Expand Down
4 changes: 2 additions & 2 deletions tests/migrations/create_email_templates_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ public function up()
$table->increments('id');
$table->unsignedInteger($columnName)->nullable();
$table->string('key', 191)->comment('Must be unique when combined with language');
$table->string('language', 8)->default(config('filament-email-templates.default_locale'),);
$table->string('language', 8)->default(config('filament-email-templates.default_locale'), );
$table->string('name', 191)->nullable()->comment('Friendly Name');
$table->string('view', 191)->default(config('filament-email-templates.default_view'))->comment('Blade Template to load into');
$table->json('from')->nullable()->comment('From address to override system default');
$table->string('send_to',191)->nullable()->comment('The Notifiable model class');
$table->string('send_to', 191)->nullable()->comment('The Notifiable model class');
$table->json('cc')->nullable();
$table->json('bcc')->nullable();
$table->string('subject', 191)->nullable();
Expand Down

0 comments on commit 5a0e99b

Please sign in to comment.