[英]How to limit unreadNotifications in Laravel?
下面的代码显示laravel中已登录用户的所有未读通知:
auth()->user()->unreadNotifications
我将代码放入标签中并将其绑定为unreads属性,以便我的vue组件可以访问未unreads
数据。
<notification :userid="{{ auth()->user()->id }}" :unreads="{{ auth()->user()->unreadNotifications }}"></notification>
一切正常。
从vue js,我可以将未读数据限制为所需的结果数。
但是,当我在浏览器中查看源代码时,可以看到显示了所有通知,因此,页面加载延迟了,因为上面有很多结果。
现在,我想限制 auth()->user()->unreadNotifications
以便我可以控制要显示的结果数。 我检查了google和laravel文档,但没有找到。 有人知道吗
Laravel Framework GitHub上存在一个问题,建议您使用:
auth()->user()->unreadNotifications()->take(10)->get()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.