22 lines
666 B
PHP
22 lines
666 B
PHP
<?php
|
|
|
|
namespace App\Mail\Concerns;
|
|
|
|
use App\Services\Email\EmailTemplateService;
|
|
|
|
/**
|
|
* Render subject+html từ Template DB (EmailTemplateService) theo scenario.
|
|
* Không còn fallback về Blade view — nếu template thiếu/tắt hoặc chứa
|
|
* variable không hợp lệ, exception sẽ propagate rõ ràng thay vì gửi email rỗng.
|
|
*/
|
|
trait RequiresDbTemplate
|
|
{
|
|
private ?array $dbRendered = null;
|
|
|
|
/** @return array{subject: string, html: string} */
|
|
protected function renderFromTemplate(string $scenario, array $vars): array
|
|
{
|
|
return $this->dbRendered ??= app(EmailTemplateService::class)->preview($scenario, $vars);
|
|
}
|
|
}
|