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

orest's avatar
Level 13

disable notifications from ignored users

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));
                 });
             }
}

0 likes
1 reply
Sergiu17's avatar

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

Please or to participate in this conversation.