我已经创建了以商店订单提交事件的通知
return [
'cart_id'=>$this->cart->id,
'text'=>'order is submitted'
];
当我从数据库中检索通知数据时
@foreach (Auth::user()->unreadNotifications as $notification )
{{$notification->data['text'] }}
@endforeach
这会将错误视为未定义的索引文本
但如果我尝试通过
访问文本@foreach ($notification->data as $key => $data)
{{$data}}
@endforeach
它有效
但为什么我无法通过$notification->data['text']
答案 0 :(得分:1)
您应该直接获得text
属性:
@foreach (Auth::user()->unreadNotifications as $notification )
{{ $notification->text }}
//Or use
{{ $notification['text'] }}
@endforeach
希望这有帮助。