Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincentvankekerix's avatar

ShouldBroadcast in Event Listener

Dear all,

I'm currently working on my project based on Spark, and I try to accomplish that whenever the Laravel\App\Events\NotificationCreated event gets fired, my event listener picks up on this and triggers ShouldBroadcast to send a notification to Pusher that a new notification has been created.

The event triggers the listener, so that all goes well, but nothing gets pushed to Pusher. There aren't any errors either, so that's not helpful.

When I implement ShouldBroadcast in the original Spark event, all gets pushed to Pusher as it should, so there are no other infrastructural problems.

Questions from my side:

  1. Is it possible to implement ShouldBroadcast in an event listener, and if so, what is the right way to do this?
  2. The reason why I'm using a listener, instead of editing the event, is because I don't want the customised Spark event to get overwritten when I upgrade Spark to a new version. Is there any way to modify a Spark event, or to swap it out?

Thanks for your help! Vincent

0 likes
2 replies
vincentvankekerix's avatar
Level 6

Thanks for letting me know, Bobby! I tried out swapping NotficiationRepository@create with a new method, which refers to my custom event, but swap does not seem to work on the NotificationRepo.

However, I got it to work by firing my new custom event (which broadcasts to Pusher) via the listener, that is listening to the original Spark event. It sounds messy, but hey - it works!

Please or to participate in this conversation.