简体   繁体   English

如何标记刚进来的Laravel通知

[英]How to mark Laravel Notifications that just came in

I have a page that displays all of the user's notifications.我有一个显示所有用户通知的页面。 I want to highlight notifications that has not yet been read by the user.我想突出显示用户尚未阅读的通知。

However, when I use但是,当我使用

$notifications = tap(auth()->user()->notifications)->markAsRead();

It automatically marks all the notifications as read and I am unable to tell the blade file which notifications are those that have already been read and which notifications are those that the user has not yet seen since he/she last visited the notifications page.它会自动将所有通知标记为已读,我无法告诉刀片文件哪些通知已被读取,哪些通知是用户自上次访问通知页面以来尚未看到的通知。 Any help would be appreciated.任何帮助,将不胜感激。 Thanks!谢谢!

You should just use unreadNotifications instead of notifications , therefore you'll mark them as read but you'll know that everyone of them was unread.您应该只使用unreadNotifications而不是notifications ,因此您会将它们标记为已读,但您会知道它们中的每个人都未读。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM