notifications[$key]); $this->notifications[$key] = $class; if ($alreadyRegistered) { continue; } Event::listen($class::listensTo(), function (object $event) use ($key) { $class = $this->notifications[$key] ?? null; if ($class == null) { return; } try { $notification = new $class($event); if (isset($event->delaySeconds) && $event->delaySeconds > 0) { $notification->delay($event->delaySeconds); } $notification->notifiable()->notify($notification); } catch (Throwable $e) { report($e); } }); } } public function unregister(string $key): void { unset($this->notifications[$key]); } public function all(): array { return $this->notifications; } }