realtime->emitToUser( RealtimeEvent::NOTIFICATION_CREATED, $notification->user_id, [ 'entity' => 'notification', 'id' => $notification->id, 'type' => $notification->type, ], ); } public function updated(Notification $notification): void { if (! $notification->wasChanged('read') || ! $notification->read) { return; } $this->realtime->emitToUser( RealtimeEvent::NOTIFICATION_READ, $notification->user_id, [ 'entity' => 'notification', 'id' => $notification->id, ], ); } }