I'm trying to get a message to show for all members of a team in Laravel once a job is created. But I've no idea how to do this. As an example say i create a job where anyone in my team can work on it. I wish to show a message on my team-mates app the next time they view the page. Something like 'Craig created job 765675. click here to open the job.'.
I realise that Session::flash( 'message', $theMessage );
isn't the way to go as this would only be for myself right? How can I do this for other users (if I can that is).
CodePudding user response:
You can create a basic notification system, if you are going to share notifications to X users. A basic notifications
table with route
/ title
/ message
fields and a user_notifications
table with user_id
/ is_read
should work for basic notifications. As an example, when you create a new job you can fire a JobCreated
event that creates 1 new notification with the information you want & adds X users (based on a team or anything else) to it. When you access your application you can request the current notifications for that authenticated user.