我可以从通知 Laravel 的数据库中获取电子邮件数据吗?

我想要的是在电子邮件通知中显示新订阅者电子邮件。我想让那些已存储在数据库中的电子邮件显示在下面的电子邮件表单中。

在你有一个新订阅者这句话之后:它会显示新订阅者的新电子邮件

http://img2.mukewang.com/6145e7a90001532607600346.jpg

这是我的通知


public function toMail($notifiable)

{

    $subscribers = Subscribe::where('email', '!=', null)->first();


    return (new MailMessage)

                ->subject('You have a new subscriber')

                ->line('You have a new subscriber:', $subscribers)

                ->action('Click Here', url('/subscribe'));

                // ->line('Thank you for using our application!');

}

我怎样才能做到这一点?


*对不起,我的英语不好


LEATH
浏览 207回答 1
1回答

MYYA

您的脚本中只有一些小问题:在此处将逗号更改为点:->line('You have a new subscriber:', $subscribers)获取对象的电子邮件属性。像这样:$subscribers->email;如果你想获得最新的订阅者(并且你的表包含 Laravel 时间戳)Subscribe::where('email', '!=', null)->orderBy('created_at','DESC')->first();总而言之,您的代码应该如下所示:public function toMail($notifiable){    $subscribers = Subscribe::where('email', '!=', null)->orderBy('created_at','DESC')->first();    return (new MailMessage)                ->subject('You have a new subscriber')                ->line('You have a new subscriber:'.$subscribers->email)                ->action('Click Here', url('/subscribe'));                // ->line('Thank you for using our application!');}
打开App,查看更多内容
随时随地看视频慕课网APP