Laravel echo change current user info

I am using laravel echo together with laravel-websockets. My question is similar to this one. I am trying to change some info on the current user when the user manually starts some action.

Right now I am doin a channel.whisper() with the userId (on a presence channel) alerting others that he is doing something. The problem is that if another users joins, or one of the other users leave and come back, or simply refresh the page, the first user status is not saved.

I understand that I need to leave the channel and rejoin with the user info updated. The user info come from the channels.php something like:

Broadcast::channel('activity', function ($user) {
     if (Auth::check()) {
        return ['id' => $user->id, 'name' => $user->name, 'avatar' => $user->avatar, 'email' => $user->email, 'active' => false];
     return false;

The question is how can I change the 'active' => true from vue frontend, then leave and rejoin the channel.

Read more here:

Content Attribution

This content was originally published by grimdbx at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: