我想为查看特定帖子的用户标记通知为已读。
它会出现这个错误。
public function show(Post $post)
{
$notification_for_user = auth()->user()->unreadNotifications()->where("data['post_id']", $post->id)->first()->update(['read_at' => now()]);
return view('post.show', compact('post'));
}
它会出现这个错误。
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'data['post_id']' in 'where clause'
当该通知显示时,我如何访问数据列的post_id以便为用户删除特定通知。
以下是数据列中存储的方式
{"post_id":8,"title":"Example Post...}
$notification_for_user = auth()->user()->unreadNotifications()->whereRaw("data.post_id", $post->id)->first()->update(['read_at' => now()]);
- Sohel0415unreadNotifications()
函数,如果你能更新一下你的问题并附上数据库模式图就更好了。 - Sohel0415