Laravel通知发送

Laravel通知发送,laravel,Laravel,我已设置通知类。当用户登录通知时显示欢迎。当我们发送通知时显示错误 调用字符串上的成员函数routeNotificationFor() 这里是SurveyNotification代码 <?php namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Illuminate\Contracts\Queue\ShouldQueue; us

我已设置通知类。当用户登录通知时显示欢迎。当我们发送通知时显示错误 调用字符串上的成员函数routeNotificationFor() 这里是SurveyNotification代码

<?php
namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use App\User;

class WelcomeToDStrokeTennis extends Notification
{
    use Queueable;

    protected $user;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(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('MyApp Welcomes You.')
            ->action('Login To MyApp',         'http://dstroketennis.com')
            ->line('Thank you for trusting MyApp!');
    }

    /**
     * Get the array representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function toArray($notifiable)
    {
        return [
        //
        ];
    }
}
设置用户 首先,您需要设置一个用户(或另一个扩展
通知
类的模型),以便通知知道“去哪里”。 你可以通过构造器,或者简单地使用

$user->notify(新的WelcomeToSurvey($request->toArray());

您可以通过
$request
对象或通过
Auth::user()
方法获取用户

提供电子邮件 您需要设置一封电子邮件,将通知发送到其中

用户
模型中添加如下内容:

public function routeNotificationForMail()
    {
        return $this->email_address; //You e-mail property here
    }
有关更多信息,请查看设置用户 首先,您需要设置一个用户(或另一个扩展
通知
类的模型),以便通知知道“去哪里”。 你可以通过构造器,或者简单地使用

$user->notify(新的WelcomeToSurvey($request->toArray());

您可以通过
$request
对象或通过
Auth::user()
方法获取用户

提供电子邮件 您需要设置一封电子邮件,将通知发送到其中

用户
模型中添加如下内容:

public function routeNotificationForMail()
    {
        return $this->email_address; //You e-mail property here
    }

有关详细信息,请查看

Now此错误显示预期响应代码220,但得到代码“”,并显示消息“”您可以更新您问题中的代码吗,因此我检查一下吗?@BilaLSIDIQNow此错误显示预期响应代码220,但得到代码“”,并显示消息“”你能在你的问题中更新你的代码吗,所以我来检查一下吗?@BilalsidIQ