class TestEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
//All public attributes will be sent with the message
public $id;
public $event = 'test_event';
public function __construct()
{
$this->id = 123;
}
public function broadcastOn()
{
//List of channels where this event should be sent
return ['/test_event'];
}
}
class TestController extends Controller
{
public function test() {
event(new TestEvent());
return view('main');
}
}