Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 未定义索引:在laravel中显示通知json数组时的用户_Php_Mysql_Json_Laravel_Notifications - Fatal编程技术网

Php 未定义索引:在laravel中显示通知json数组时的用户

Php 未定义索引:在laravel中显示通知json数组时的用户,php,mysql,json,laravel,notifications,Php,Mysql,Json,Laravel,Notifications,当尝试显示json数据时,它会给出未定义的索引:user exception foreach(auth()->user()->unreadnotifications as $notifications) @include('frontend.common.notification.'.snake_case(class_basename($notifications->type))) @endforeach 包含的视图代码是 <div>

当尝试显示json数据时,它会给出未定义的索引:user exception

  foreach(auth()->user()->unreadnotifications as $notifications)

       @include('frontend.common.notification.'.snake_case(class_basename($notifications->type)))

  @endforeach
包含的视图代码是

  <div>
    <i class="fa fa-comment fa-fw"></i>
    <img src="{{url('images/account/'.$notifications->data['user']['currentimage'])}}" height="50px" width="50"/>
    {{$notifications->data['user']['email']}} commented on your post.
    <span class="pull-right text-muted small">{{$notifications->created_at->diffForHumans()}}</span>
</div>

数据['user']['currentimage']}}“height=“50px”width=“50”/
{{$notifications->data['user']['email']}对您的帖子发表了评论。
{{$notifications->created_at->diffForHumans()}
Json对象是

{“评论”:{“评论”:“我很棒”,“用户id”:2,“发布id”:“2”,“通信率”:90,“更新地址”:“2017-07-06 16:32:07”,“创建地址”:“2017-07-06 16:32:07”,“id”:18},“用户”:{“id”:2,“电子邮件”:”test2@mail.com“,“currentimage”:“1499004938.jpg”,“角色”:0,“已验证”:null,“已阻止”:null,“创建于”:“2017-07-02 13:44:24”,“更新于”:“2017-07-02 14:15:38”}”


在查看代码之后,我假设您正在集合上使用foreach循环

  <div>
<i class="fa fa-comment fa-fw"></i>
<img src="{{url('images/account/'.$notifications->user->currentimage}}" height="50px" width="50"/>
{{$notifications->user->email}} commented on your post.
<span class="pull-right text-muted small">{{$notifications->created_at->diffForHumans()}}</span>

用户->当前图像}}“height=“50px”width=“50”/
{{$notifications->user->email}}对您的帖子发表了评论。
{{$notifications->created_at->diffForHumans()}