我觉得我在这里错过了一些非常简单的东西,但是我有一个像这样的脚本:
\Mail::to( User::all() )
->send( new NotificationEmail($notification) );
class NotificationEmail extends Mailable {
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @param Notification $notification
*
*/
public function __construct( Notification $notification ) {
$this->notification = $notification;
}
/**
* Build the message.
*
* @return $this
*/
public function build() {
$notification = $this->notification;
return $this
->from( [
'address' => \env( 'MAIL_DEFAULT_SENDER' ),
'name' => \env( 'APP_NAME' )
] )
->view( 'email.notification.ready' );
}
}
现在,我希望电子邮件的开头能够像这样:
亲爱的{用户的名字}, 但是我不知道如何获取将收到该电子邮件的用户的名字。有没有办法找出来呢?