Boubou
1 week ago

Need feedback from on the best way to organize event notifications with Pusher

Posted 1 week ago by Boubou

Hello,

I would like to know if you could give me some feedback on this please as I am not sure how to structure my app.

I have a controller that calculates: The number of accepted posts(private to the user) The number of refused posts(private to the user) The number of reviewed posts(private to the user) The number of newly created posts(public).

At the moment I have created a controller that calls all this data and sends it to pusher each time the user logs in.

My controller returns an event with an array as:

        return event(new UpdateAndroidCounts([
            "accepted" => $accepted,
            "refused" => $refused,
            "reviewed" => $reviewed,
            "created" => $created,
            "user_id" => $id
        ]));

As you can see, for my event to work, it has to be embedded inside this controller due to all the calculations being generated before the event.

My problem now is that each time a post is created, accepted, refused, reviewed in the other controller, I need to call this controller to generate the event for pusher.

How to do this, please?

How to call this controller from another one but also keep the details of the request.

Would this be the right away of using pusher or shall I create all the calculations inside the event itself?

Thank you.

Please sign in or create an account to participate in this conversation.