JonoCoetzee
JonoCoetzee

Reputation: 969

Laravel user notification feature

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.

Upvotes: 0

Views: 2107

Answers (1)

dpak005
dpak005

Reputation: 241

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

Upvotes: 1

Related Questions