Load mail layouts from view files if not found in the database (#4904)
Brings mail layouts more in line with the rest of the mail template pieces by loading from the relevant view files when the layout doesn't exist in the database.
This commit is contained in:
parent
d3596310c6
commit
9995dddc75
|
|
@ -71,6 +71,19 @@ class MailLayout extends Model
|
|||
return array_get(self::listCodes(), $code);
|
||||
}
|
||||
|
||||
public static function findOrMakeLayout($code)
|
||||
{
|
||||
$layout = self::whereCode($code)->first();
|
||||
|
||||
if (!$layout && View::exists($code)) {
|
||||
$layout = new self;
|
||||
$layout->code = $code;
|
||||
$layout->fillFromView($code);
|
||||
}
|
||||
|
||||
return $layout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loops over each mail layout and ensures the system has a layout,
|
||||
* if the layout does not exist, it will create one.
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ class MailTemplate extends Model
|
|||
$this->subject = array_get($sections, 'settings.subject', 'No subject');
|
||||
|
||||
$layoutCode = array_get($sections, 'settings.layout', 'default');
|
||||
$this->layout_id = MailLayout::getIdFromCode($layoutCode);
|
||||
$this->layout = MailLayout::findOrMakeLayout($layoutCode);
|
||||
}
|
||||
|
||||
protected static function getTemplateSections($code)
|
||||
|
|
|
|||
Loading…
Reference in New Issue