我正在尝试将用户详细信息传递给我的通知,以便我可以说:亲爱的用户名,但无法弄清楚如何。另外,我期待在验证用户时获得默认 URL。所以,基本上我只想更改我的 toMail 函数中的第一个 ->line() 。
在用户模型中:
public function sendEmailVerificationNotification()
{
$this->notify(new CustomVerifyEmail($this->user));
}
在 CustomVerifyEmail 类中
public $user;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(User $user)
{
$this->user = $user;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->line('The introduction to the notification.'.$this->user->email)
->action('Notification Action', url('/'))
->line('Thank you for using our application!');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}