【发布时间】:2018-02-04 16:55:18
【问题描述】:
我现在正在实施 laravel 通知。通知存储在通知表中。我试图获取数据列中的数据并在刀片中显示但失败了。
这是我的控制器
public function notification_list(){
$notifications = auth()->user()->notifications()->orderBy('created_at','desc')->get();
return view('users.notification.index')->with('notifications',$notifications);
}
这将返回通知集合。但是我无法获取消息等数据。如何提取“数据”并转换为数组?
【问题讨论】:
-
你的 $notifications 变量打印什么。??
-
可以使用 toArray() 方法转换为数组。
-
@nikhil_gandhi 是的,它现在工作了,谢谢你的帮助。
-
我已添加为答案。请接受。