错误在$ user-> notify($ natifictionclass) - > delay()

时间:2017-02-03 07:15:24

标签: laravel laravel-5.3 task-queue

在null

上调用成员函数delay()

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

通知类我正在geting.in作业表数据是存储但我在调用成员函数延迟null时出错。可以帮助我。

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;

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

通知类

    namespace App\Notifications;

    use App\Channels\PushChannel;
    use App\Channels\SmsChannel;
    use App\Libraries\Helper;
    use App\Waitlists;

    use Illuminate\Bus\Queueable;
    use Illuminate\Notifications\Notification;
    use Illuminate\Contracts\Queue\ShouldQueue;
    use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

    use Illuminate\Queue\SerializesModels;
    use Illuminate\Queue\InteractsWithQueue;

    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 \Illuminate\Notifications\Messages\MailMessage
     */

    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

1 个答案:

答案 0 :(得分:0)

$guest->notify($waitPreCall)返回null,这就是您收到错误的原因。检查notify()的定义,看看发生了什么。