Aar*_*ron 4 php notifications laravel laravel-notification
我正在使用 Laravel 发送通知,但无法弄清楚如何发送第二个操作。这是我的toMail方法代码:
public function toMail($notifiable)
{
return (new MailMessage)
->subject($this->options['subject'])
->greeting($this->options['greeting'])
->line($this->options['contentParagraph1'])
->line($this->options['contentParagraph2'])
->action('Facebook', 'https://www.facebook.com/')
->line($this->options['contentParagraph5'])
->action('LinkedIn', 'https://www.linkedin.com/')
->line($this->options['contentParagraph3'])
->line($this->options['contentParagraph4'])
->salutation($this->options['salutation']);
}
Run Code Online (Sandbox Code Playgroud)
我得到的只是第二个动作。看起来第二个操作覆盖了第一个操作。有没有办法保留这两个操作或使用链接而不是按钮?
该SimpleMessage班是专为创建具有一个号召性按钮简单的信息,你可以找到的代码,权力的功能照亮/通知/消息/ SimpleMessage.php并为SimpleMessage中的电子邮件模板可以在找到照亮/通知/ resources/views/email.blade.php — 注意单个按钮。
您可以使用Markdown 邮件通知功能创建更复杂的消息,这将允许您包含任意数量的按钮。你可以这样实现:
markdown选项,例如:php artisan make:notification InvoicePaid --markdown=mail.invoice.paidviews/mail/invoice/paid.blade.php添加任意数量的按钮,例如:
@component('mail::message')
# Introduction
@component('mail::button', ['url' => $url1])
Button 1 Text
@endcomponent
@component('mail::button', ['url' => $url2])
Button 2 Text
@endcomponent
@component('mail::button', ['url' => $url3])
Button 3 Text
@endcomponent
Thanks,<br>
{{ config('app.name') }}
@endcomponent
Run Code Online (Sandbox Code Playgroud)SimpleMessage在构建电子邮件时,将您对方法的调用替换为对 Markdown 模板的引用,例如:
return (new MailMessage)
->subject($this->options['subject'])
->markdown('mail.invoice.paid', $this->options);
Run Code Online (Sandbox Code Playgroud)该markdown方法中的第二个参数是要传递到您的视图中的数组,通过它您可以包含要包含在电子邮件中的各种值,例如contentParagraph1、greeting和salutation。
| 归档时间: |
|
| 查看次数: |
5281 次 |
| 最近记录: |