【发布时间】:2019-05-12 07:27:12
【问题描述】:
我在 laravel 中合并通知和队列时遇到问题...
如果我不使用队列并这样写通知
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use Illuminate\Notifications\Messages\MailMessage;
class InterestingOfferPosted extends Notification
{
public $offer;
public function __construct($offer)
{
$this->offer = $offer;
}
public function via($notifiable)
{
return ['mail'];
}
public function toMail($notifiable)
{
return (new MailMessage)
->subject('New Offer')
->line("You have new offer: ".$this->offer->name }
}
这很好用,最后我得到了正确的文本,但是如果我让这个类实现“Illuminate\Contracts\Queue\ShouldQueue”类并使用“Illuminate\Bus\Queueable”特征,用户将收到默认的 laravel“The通知介绍。”邮件。 队列在任何其他情况下都很好,所以我认为我是对的,但在这种特殊情况下,它会改变最终结果。 有什么想法吗?
【问题讨论】:
标签: laravel notifications queue