visualbuilder / email-templates

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

EmailTemplate model theme relation issue on foreign key #5

Closed EvangelosGeorgiou closed 3 months ago

EvangelosGeorgiou commented 7 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 3 months 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.