【发布时间】:2017-05-22 06:22:10
【问题描述】:
我正在使用视图编辑器从该表中获取数据并将其发送回我的视图
class NavComposer
{
public function compose(View $view)
{
if (Auth::check()) {
$view->with('unread_notifications', DB::table('notifications')->where([
['read_at', '=', NULL],
['notifiable_id', '=', Auth::user()->id],
])->get());
}
}
}
我的看法:
@foreach($unread_notifications as $notification)
{{ $notification->data }}
@endforeach
我得到了什么:
{"id":79,"sender":"Diana","receiver":"Alex","subject":"Subject","body":"Lorem ipsum"}
我要显示的内容:
ID: 79
Subject: Subject
Body: Lorem Ipsum
如果这是我对 JSON 不太了解的非常简单的东西,我提前道歉
【问题讨论】: