dynamic email templates

This commit is contained in:
denisdulici
2020-01-09 15:24:52 +03:00
parent 2ea379c8f5
commit 807187f0a3
5 changed files with 74 additions and 253 deletions

View File

@@ -37,11 +37,7 @@ class Email extends Controller
return $s;
})->pluck('value', 'key');
EmailTemplate::all()->each(function ($template) use ($setting) {
$setting->put('template_' . $template->alias . '_subject', $template->subject);
$setting->put('template_' . $template->alias . '_body', $template->body);
$setting->put('template_' . $template->alias . '_params', $template->params);
});
$templates = EmailTemplate::all();
$email_protocols = [
'mail' => trans('settings.email.php'),
@@ -50,16 +46,10 @@ class Email extends Controller
'log' => trans('settings.email.log'),
];
$invoice_tags = implode(', ', app('App\Notifications\Sale\Invoice')->getTags());
$payment_tags = implode(', ', app('App\Notifications\Portal\PaymentReceived')->getTags());
$bill_tags = implode(', ', app('App\Notifications\Purchase\Bill')->getTags());
return view('settings.email.edit', compact(
'setting',
'templates',
'email_protocols',
'invoice_tags',
'payment_tags',
'bill_tags'
));
}
@@ -117,8 +107,6 @@ class Email extends Controller
$template = EmailTemplate::alias($alias)->first();
$template->update([
'company_id' => $template->company_id,
'alias' => $template->alias,
'subject' => $fields[$subject_key],
'body' => $fields[$body_key],
]);

View File

@@ -6,7 +6,6 @@ use App\Abstracts\Model;
class EmailTemplate extends Model
{
protected $table = 'email_templates';
/**
@@ -14,7 +13,7 @@ class EmailTemplate extends Model
*
* @var array
*/
protected $fillable = ['company_id', 'alias', 'subject', 'body', 'params'];
protected $fillable = ['company_id', 'alias', 'class', 'name', 'subject', 'body', 'params'];
/**
* Scope to only include contacts of a given type.