在 $user->notify($natifictionclass)->delay() 中调用时,对 null 上的成员函数 delay() 调用时出错



调用成员函数 delay() on null

当我用 dealy 调用通知方法时,我正在上面。

通知类我正在存储 getting.in 作业表数据,但我在调用成员函数时出现错误 null 延迟。 有人可以帮助我吗?

use IlluminateDatabaseEloquentModel;
use IlluminateNotificationsNotifiable;
class User extends Model
{
    //
    use Notifiable;
    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'user';
    /**
     .....
}

通知类

    namespace AppNotifications;
    use AppChannelsPushChannel;
    use AppChannelsSmsChannel;
    use AppLibrariesHelper;
    use AppWaitlists;
    use IlluminateBusQueueable;
    use IlluminateNotificationsNotification;
    use IlluminateContractsQueueShouldQueue;
    use IlluminateContractsBroadcastingShouldBroadcast;
    use IlluminateQueueSerializesModels;
    use IlluminateQueueInteractsWithQueue;
    class WaitingPrecall extends Notification implements  ShouldBroadcast
    {
    use Queueable;
    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public $message;
    public $phone;

    public $deviceGuests;
    public function _construct()
    {
    }
    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return $this->sendtype==1?[PushChannel::class]: [PushChannel::class,SmsChannel::class];
    }
    /**
     * Get the mail representation of the notification.
     *
     * @param  mixed  $notifiable
     * @return IlluminateNotificationsMessagesMailMessage
     */
    public function toSms($notifiable)
    {
         $data=Helper::send_message($this->smstext,$this->phone);
         return $data;
    }
}

函数调用

$waitPreCall=new WaitingPrecall();
....
....
$guest=User::find($waitDataNew->user->gust_id);
 $guest->notify($waitPreCall)->delay($when);//here i am getting error

$guest->notify($waitPreCall)返回 null,这就是您收到错误的原因。检查notify()的定义以了解正在发生的事情。

最新更新