[Vuejs]-How to listen broadcast events into vue app from laravel app

2👍

VueJs

  window.Echo.channel("channel-name").listen(".channel-app", e => {
    console.log(e);
 });

Laravel

Event

public function broadcastOn()
{
    return new Channel('channel-name');
}

public function broadcastAs()
{
    return 'channel-app';
}

Controller

public function test()
{
    broadcast(new MessageSent());
}

channel

Broadcast::channel('channel-name', function(){ return true; });

Leave a comment