Laravel 5.6
我正在尝试通过电子邮件发送Laravel通知。我想让一些文本变粗,并放入换行符,而没有line($text)
方法带来的全新段落。所以我在通知类中试过这个。我也尝试使用\n
字符串换行。
return (new MailMessage)
->subject('Booking Confirmed - Please Read')
->greeting('Hello ' . $this->booking->user->first_name . ',')
->line('Thank you for booking. Here are your booking details:')
->line($this->booking->provider->providerType->name . '<br>' .
$date . '<br>' .
$this->booking->start_at . '<br>' .
$this->booking->address_1 . '<br>' .
$this->booking->address_2 . '<br>' .
$this->booking->address_3 . '<br>' .
$this->booking->city . '<br>' .
$this->booking->postcode . '<br>' .
'£' . $this->booking->price
)
->line('<strong>Need to cancel?</strong><br>' .
'Don\'t forget to contact the provider on the details above if you need to cancel or reschedule.
They won\'t mind, as long as you tell them.'
)
->line('<strong>Payment</strong><br>' .
'Pay the Service provider direct as you normally would. This keeps things simple and costs down.'
)
->line('<strong>FAQ\'s</strong><br>' .
'Please click here for more information'
)
->line('<strong>Don\'t forget to leave feedback after!</strong><br>' .
'Help build your relationship with your Service Providers by leaving feedback'
)
->line('We hope to see you again soon!')
我试过通过php artisan vendor:publish --tag=laravel-mail
命令发布和不发布刀片模板,然后将{{$line}}
更新为{!! $line !!}}
,没有任何乐趣。无法弄清楚。
使用带单引号的正常换行符
'This will create a
new line'
或使用带双引号的\n
"This will also create a \n new line"
您需要确实更新通知视图,以便您处于正确的轨道上。
基本上在发布通知包的资源之后:
$ php工匠供应商:publish --tag = laravel-notifications
您需要做的就是打开资源/ views / vendor / notifications / email.blade.php并用{!!替换{{$ line}}的出现次数。 $ line !!}。
这只是告诉Blade不要逃避标签。
希望这可以帮助!