change icons, css, add routing to merchandise, add mail templater, fixes
This commit is contained in:
64
app/Repositories/Core/Mail/MailTemplates.php
Normal file
64
app/Repositories/Core/Mail/MailTemplates.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Core\Mail;
|
||||
|
||||
use App\Models\Core\Mail\MailTemplate;
|
||||
use App\Traits\Model\Basic;
|
||||
use Mustache_Engine;
|
||||
|
||||
class MailTemplates
|
||||
{
|
||||
use Basic;
|
||||
|
||||
public static function init()
|
||||
{
|
||||
return [
|
||||
'mailables' => Mailables::getList(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function edit($id)
|
||||
{
|
||||
$data = self::get($id)->toArray();
|
||||
$mailable = $data['mailable'];
|
||||
$data['vars'] = $mailable::getVariables();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getVarsByMailable($mailable)
|
||||
{
|
||||
return $mailable::getVariables();
|
||||
}
|
||||
|
||||
public static function getDataFormodalPreview($id)
|
||||
{
|
||||
$template = self::get($id);
|
||||
$mailable = $template->mailable;
|
||||
|
||||
return [
|
||||
'id' => $id,
|
||||
'users' => $mailable::getUsers(),
|
||||
];
|
||||
}
|
||||
|
||||
public static function preview($id, $user_id)
|
||||
{
|
||||
$template = self::get($id);
|
||||
$mailable = $template->mailable;
|
||||
$data = $mailable::getDataByUser($user_id);
|
||||
$html_template = $template->toArray()['html_template_translations'][$data['lang']] ?? false;
|
||||
if ($html_template) {
|
||||
$m = new Mustache_Engine();
|
||||
|
||||
return $m->render($html_template, $data);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getModel()
|
||||
{
|
||||
return MailTemplate::query();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user