Level 60
You should not modify code from vendor directory, either in each event listener or create a new class and overwrite notify method, and each event will extend from the created class
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I want to disable notifications from ignored/blocked users
Would it be bad idea to add a condition in the notify helper ?
/**
* Send the given notification.
*
* @param mixed $instance
* @return void
*/
public function notify($instance)
{
if(auth()->user()->isIgnored($this))
{
return;
}
app(Dispatcher::class)->send($this, $instance);
}
Or should I add this condition in each event listener class that is responsible for sending the notification
class NotifyConversationParticipants
{
public function handle(NewMessageWasAddedToConversation $event)
{
$event->participants->each(function($participant){
if(auth()->user()->isIgnored($participant)
{
return;
}
$participant->notify(new ConversationHasNewMessage($event->message));
});
}
}
Please or to participate in this conversation.