duanhe1976 2014-07-03 17:21
浏览 129
已采纳

Laravel用户通知功能

I'm trying to implement a notification feature in a Laravel 4 application that I'm building. 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. For argument's sake, neither GroupA nor GroupB are a finite number of users but GroupB will be larger than 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. This is assuming that Laravel updates last_activity at the end of the request instead of the beginning. 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. 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? 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? 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.

  • 写回答

1条回答 默认 最新

  • dparivln22034 2015-04-26 08:13
    关注

    The attached link may solve your problem : http://ryantablada.com/post/an-eloquent-notification-strategy

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器