【发布时间】:2018-03-17 18:10:40
【问题描述】:
我正在使用 Laravel 的通知系统在用户注册时发送欢迎电子邮件。一切都很好,除了我一生无法弄清楚如何在问候语中插入换行符。
这是我的代码:
namespace App\Notifications\Auth;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
class UserRegistered extends Notification
{
public function via($notifiable)
{
return ['mail'];
}
public function toMail($notifiable)
{
return (new MailMessage)
->subject('Welcome to website!')
->greeting('Welcome '. $notifiable->name .'!')
->line('## Sub heading line')
->line('Paragraph line')
->markdown('mail.welcome');
}
}
我想在->greeting('Welcome '. $notifiable->name .'!') 在欢迎词和名字之间打断一下。有谁知道我该怎么做?我已经尝试过降价文档中描述的双倍空格。我试过使用nl2br()。我试过了\n。我试过<br>。没有任何效果。
【问题讨论】:
-
你推荐过这篇文章吗?
stackoverflow.com/questions/26626256/… -
是的。试过了
-
@james.brndwgn 在双引号中使用
-
@shashi 我不确定您所说的“双引号”是什么意思,但我尝试过使用像
->greeting('Welcome<br>'. $notifiable->name .'!')这样的
,所做的只是打印出“Welcome
name” -
@james.brndwgn 它也可以工作
标签: php laravel laravel-5.4