我正在尝试更改默认设置 subject
Laravel 5.7 附带的验证电子邮件中的字段。我如何以及在哪里更改它?我已经到处和网上搜索了。因为它是全新的我找不到答案。
最佳答案
你不需要编码任何东西。通知将所有字符串都包装在 Lang 类中,以便您可以提供从英语到另一种语言的翻译字符串,如果您只想更改措辞,甚至可以提供从英语到英语的翻译字符串。
查看/vendor/laravel/framework/src/Illuminate/Auth/Notifications/VerifyEmail.php
public function toMail($notifiable)
{
if (static::$toMailCallback) {
return call_user_func(static::$toMailCallback, $notifiable);
}
return (new MailMessage)
->subject(Lang::getFromJson('Verify Email Address'))
->line(Lang::getFromJson('Please click the button below to verify your email address.'))
->action(
Lang::getFromJson('Verify Email Address'),
$this->verificationUrl($notifiable)
)
->line(Lang::getFromJson('If you did not create an account, no further action is required.'));
}
你可以在那里看到所有的字符串。
如果您的 resources/lang 文件夹中还没有 en.json 文件,请创建一个文件。
添加原始字符串和替换。
例如
{
"Verify Email Address": "My preferred subject",
"Please click the button below to verify your email address.":"Another translation"
}
要翻译成另一种语言,请更改 config/app.php 中的语言环境并使用 locale.json 创建翻译文件
关于laravel - 在 Laravel 5.7 中更改验证电子邮件的默认 “Subject” 字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52408042/