2017-02-03 2 views
0

コール()は私が上記取得しています私はdealyとnotifyメソッドを呼び出しています。

通知クラス私はgeting.inジョブテーブルのデータはストアですが、nullのメンバ関数の遅延の呼び出しでエラーが発生しています。私はそれを助けることができます。

$waitPreCall=new WaitingPrecall(); 

.... 
.... 

$guest=User::find($waitDataNew->user->gust_id); 

$guest->notify($waitPreCall)->delay($when);//here i am getting error 

答えて

0

$guest->notify($waitPreCall)ため

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; 
    } 
} 

関数呼び出しはエラーを取得している理由です、nullを返しています。 notify()の定義をチェックして、何が起こっているかを確認してください。

+0

しかし、それがあるlaravel機能 –

+0

確かである、そしてあなたは、ソースコードに加えてlaravelサイトに与える –

+0

https://laravel.com/docs/5.3/notifications –

関連する問題