这是默认的 Laravelnotifications data字段
{
"type":"Update Appointment",
"appointment_id":"379",
"date":null,
"updated_by":"Mahir",
"status":"2"
}
Run Code Online (Sandbox Code Playgroud)
在controller我想获得所有通知status = 2并将其标记为已读
Laravel 5.3 文档显示
$user = App\User::find(1);
foreach ($user->unreadNotifications as $notification) {
$notification->markAsRead();
}
Run Code Online (Sandbox Code Playgroud)
我如何修改它以获取所有通知 status = 2
更新:寻找这样的东西
$noti = $user->unreadNotifications->where('data->status',"2");
Run Code Online (Sandbox Code Playgroud)
注意:我的数据库不支持json数据类型。