某些用户有另一个电子邮件地址,该地址存储为 users
表中的 secondary_email
列。
如何使用 $user->notify()
向该辅助电子邮件地址发送通知?
最佳答案
您将重写通知的 toMail
方法。例如:
use App\Mail\InvoicePaid as Mailable;
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return Mailable
*/
public function toMail($notifiable)
{
return (new Mailable($this->invoice))
->to($this->user->secondary_email ?? $this->user->email);
}
您可以阅读有关格式化通知的更多信息 here .
关于php - Laravel 使用另一封电子邮件向(通知)用户发送电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59923742/