visualbuilder / email-templates

Email Template Editor for Filament
GNU General Public License v3.0
62 stars 18 forks source link

EmailTemplate model theme relation issue on foreign key #5

Closed EvangelosGeorgiou closed 1 month ago

EvangelosGeorgiou commented 5 months ago

Currently the theme() relation foreign key on the EmailTemplate model is like this

public function theme() { return $this->belongsTo(EmailTemplateTheme::class, 'vb_email_templates_themes_id')->withDefault(function ($model) { return EmailTemplateTheme::where('is_default', true)->first(); }); }

you should get the table name from the config file and add the 'id' in the end

return $this->belongsTo(EmailTemplateTheme::class, config('filament-email-templates.theme_table_name') . '_id')->withDefault(function ($model) { return EmailTemplateTheme::where('is_default', true)->first(); });

cannycookie commented 1 month ago

Hey thank you for reporting and so sorry haven't replied sooner :-(. You know how sometimes life happens.

This has been fixed, thank you for letting us know and hope you sorted your own workaround.