I'm using Laravel Echo with a presence channel. All my events are working.. .here(), .joining() and .leaving()
Let's say a user is the first to join this presence channel. As other users join the .here() and .joining() events will allow a list of online users to become populated, with their ids and their names.
What if a user updates their name after joining. When this happens, all the other users do not receive an update to let them know the name of one of the users in the presence channel has been updated.
I want to achieve this, I want it so that when one user makes an update to one of the attributes which is returned from the Broadcast::channel, such as the name attribute, then all other users in the presence channel should somehow be able to know an update has been done and to get the updated data
I suppose I could trigger this with a whisper event, or I could trigger all kinds of broadcast events to "notify users" of an update. However I'm thinking that my "source of truth" should be my presence channel and that's where I build and maintain my list of "online users".
I hope I'm making sense.. so is there a way to force .here() to retrieve a new list of all users inside the presence channel and retrieve their updated attributes from the back-end?
Many thanks
Checkout for Broadcast Model update maybe the think you are looking for, https://laravel.com/docs/8.x/broadcasting#model-broadcasting , then user update his model you can notify the channels he is on. Be careful with mass asign tho. You must call User $user->save() to change to be detected.