我创建了通知功能并得到此错误“Undefined index:user”如何解决?

时间:2017-11-29 07:29:58

标签: php laravel push-notification notifications undefined

我正在创建通知功能,当用户回复帖子时,它应该向帖子的所有者发送通知。但是出现了错误 未定义的索引:问题。我可以知道如何解决它。

app.blade

  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" 
 aria- expanded="false">
 <span class="glyphicon glyphicon-globe"> </span> notification <span 
 class="badge">{{count(auth()->user()->unreadNotifications)}}</span>
</a>

 <ul class="dropdown-menu" role="menu">

   <li>  
   @foreach(auth()->user()->unreadNotifications as $notification)
      @include('layouts.partials.notification.'.snake_case(class_basename($notification->type))) 
   @endforeach

    </li>
 </ul>

模型

   class RepliedToPost extends Notification
  {
   use Queueable;
     protected $postqs;


public function __construct($postqs)
{
    $this->postqs=$postqs;

}


public function via($notifiable)
{
    return ['database'];
}


public function toDatabase($notifiable)
{
    return [
      'postqs'=>$this->postqs,
      'user'=>$notifiable

    ];
}

}

通知刀片文件

  {{$notification->data['user']['name']}} commmented on 
  {{$notification>data['postqs']['question']}}

1 个答案:

答案 0 :(得分:0)

&#34;问题&#34;数据[&#39; postqs&#39;]数组

中不存在