hyperf-chat/app/Template/MailerTemplate.php

45 lines
1.1 KiB
PHP
Raw Normal View History

2021-02-04 23:36:14 +08:00
<?php
2021-08-31 22:33:41 +08:00
declare(strict_types=1);
2021-02-04 23:36:14 +08:00
2022-01-23 15:13:58 +08:00
namespace App\Template;
2021-02-04 23:36:14 +08:00
2021-05-24 11:31:36 +08:00
use Throwable;
2021-02-04 23:36:14 +08:00
/**
2021-08-31 22:33:41 +08:00
* 邮件视图模板库
2021-04-20 16:30:57 +08:00
*
2021-08-31 22:33:41 +08:00
* @package App\Templates
2021-02-04 23:36:14 +08:00
*/
2021-08-31 22:33:41 +08:00
class MailerTemplate extends BaseTemplate
2021-02-04 23:36:14 +08:00
{
/**
2021-05-24 11:31:36 +08:00
* 验证码通知 - 邮件模板
2021-02-04 23:36:14 +08:00
*
* @param string $sms_code 验证码
2021-04-20 16:30:57 +08:00
* @param array $params 模板参数
2021-02-04 23:36:14 +08:00
* @return string
*/
2021-08-31 22:33:41 +08:00
public function emailCode(string $sms_code, array $params = []): string
2021-02-04 23:36:14 +08:00
{
return $this->view(config('view.engine'), 'emails.verify-code', [
'service_name' => $params['service_name'] ?? "邮箱绑定",
'sms_code' => $sms_code,
'domain' => $params['web_url'] ?? config('domain.web_url')
]);
}
/**
2021-05-24 11:31:36 +08:00
* 系统错误通知 - 邮件模板
*
* @param Throwable $throwable
* @return string
2021-02-04 23:36:14 +08:00
*/
2021-08-31 22:33:41 +08:00
public function errorNotice(Throwable $throwable): string
2021-02-04 23:36:14 +08:00
{
2021-05-24 11:31:36 +08:00
return $this->view(config('view.engine'), 'emails.error-notice', [
2021-06-30 19:27:49 +08:00
'throwable' => $throwable->getTraceAsString(),
'message' => $throwable->getMessage()
2021-05-24 11:31:36 +08:00
]);
2021-02-04 23:36:14 +08:00
}
}