我想将查看特定帖子的用户的通知标记为已读
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...}
最佳答案
请检查以下代码。
use Illuminate\Notifications\DatabaseNotification;
$notification = DatabaseNotification::find( $request->notification_id );
$notification->update(['read_at' => now()]);
$notification->save();
关于php - 如何将特定用户的通知标记为已读并在 laravel 5 中发布?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48299740/