Some users have another email address that is stored as secondary_email
column in users
table.
How to send Notification using $user->notify()
to this secondary email address?
You would override the toMail
method of your notification. For example:
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);
}
You can read more about formatting notifications here.