Add helper for listing file + db templates

This commit is contained in:
Samuel Georges 2015-08-24 20:31:44 +10:00
parent 90d2b87180
commit 942a8c000e
1 changed files with 17 additions and 0 deletions

View File

@ -45,6 +45,23 @@ class MailTemplate extends Model
protected static $registeredTemplates;
/**
* Returns an array of template codes and descriptions.
* @return array
*/
public static function listAllTemplates()
{
$fileTemplates = (array) self::make()->listRegisteredTemplates();
$dbTemplates = (array) self::lists('description', 'code');
$templates = $fileTemplates + $dbTemplates;
ksort($templates);
return $templates;
}
/**
* Syncronise all file templates to the database.
* @return void
*/
public static function syncAll()
{
$templates = self::make()->listRegisteredTemplates();