简体   繁体   English

Laravel用户通知功能

[英]Laravel user notification feature

I'm trying to implement a notification feature in a Laravel 4 application that I'm building. 我正在尝试在要构建的Laravel 4应用程序中实现通知功能。 At the moment there is only one scenario that causes a notification to be posted but it could expand to be multiple. 目前,只有一种情况会导致发布通知,但它可能会扩展为多个。 The condition at the moment involves notifying a member of GroupA when a user in GroupB performs an action involving them. 当前的条件包括当GroupB中的用户执行涉及他们的操作时通知GroupA的成员。 For argument's sake, neither GroupA nor GroupB are a finite number of users but GroupB will be larger than GroupA. 出于争论的考虑,GroupA和GroupB都不是有限的用户,但是GroupB将大于GroupA。

My initial reaction was to get the last_activity from the session and compare it to the necessary table in the DB to see if there are any items created after that, based on the created_at field. 我的最初反应是从会话中获取last_activity并将其与数据库中的必要表进行比较,以基于created_at字段查看此后是否创建了任何项目。 This is assuming that Laravel updates last_activity at the end of the request instead of the beginning. 假设Laravel在请求的末尾而不是开始时更新了last_activity What I'm having my doubts about is that I'd have to fetch the last_activity and then do a lookup on the table for every request that the user in GroupA makes. 我对此感到疑惑的是,我必须获取last_activity ,然后针对GroupA中用户发出的每个请求在表上进行查找。 I don't think that will scale to well. 我认为这不会很好。

Secondly, I thought of some sort of queue? 其次,我想到了某种队列? Something like beanstalk. 有点像豆茎。 If I used beanstalk would it be possible for a user in GroupA to pull all actions that pertain to them (based on user_id) leaving those that aren't for them? 如果我使用beantalk,GroupA中的用户是否可以拉出所有与他们相关的操作(基于user_id),而不使用那些不适合他们的操作? Or will I need to implement a separate queue for each user? 还是我需要为每个用户实施一个单独的队列? Is that possible for a group that could potentially be 1000+ users big? 对于可能有1000多个用户的小组来说,这可能吗? Would these queues stay active for an indefinite period allowing notifications to be pushed to them and pulled in by the user when they next login? 这些队列是否会无限期保持活动状态,以允许在用户下次登录时将通知推送给他们并由用户拉入? I've never used queues before, I understand the concept but I'm not sure of the implementation. 我以前从未使用过队列,虽然我了解这个概念,但不确定执行情况。

Let me know if there's something else I should be doing, haven't implemented something like this before. 让我知道是否还有其他事情我应该做,以前没有实现过。

附件链接可能会解决您的问题: http : //ryantablada.com/post/an-eloquent-notification-strategy

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

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