http = $http; $this->socket_url = $socket_url; } /** * Send the given notification. * * @param mixed $notifiable * @param \Illuminate\Notifications\Notification $notification * @return void */ public function send($notifiable, Notification $notification) { $message = $notification->toSocket($notifiable); $message->to($notifiable->routeNotificationFor('socket', $notification)); if (! $message->to) { return; } try { $this->http->post($this->socket_url . '/emit/' . $message->to, [ 'headers' => [ 'Content-Type' => 'application/json', ], 'json' => ['data' => $message->data], ]); } catch (\GuzzleHttp\Exception\ConnectException $e) { report($e); } } }