小编Ja2*_*a22的帖子

从“通知”表“数据”字段过滤通知 - Laravel

这是默认的 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数据类型。

notifications laravel laravel-5.3

6
推荐指数
2
解决办法
2133
查看次数

标签 统计

laravel ×1

laravel-5.3 ×1

notifications ×1