subscription; $user = $subscription->user; try { $client = new Client([ 'base_uri' => config('services.notification_service.base_uri'), ]); $headers = [ 'Authorization' => config('services.notification_service.key'), ]; $body = new \stdClass(); $body->title = $event->mailTitle; $body->message = $event->mailMessage; $body->email = $user->email; $client->request('POST', '/send-mail', ['json' => $body, 'headers' => $headers]); if (isset($event->notification)) { $body = new \stdClass(); $body->user_code = $user->user_code; $body->message = $event->notification; $body->data = []; try { $body->date = $this->getCurrentTimeByCountryCode($user->network->country->code_country); } catch (Throwable $t) { Log::error($t->getMessage()); $body->date = date('Y-m-d H:i:s'); } $client->request('POST', '/onesignal/pushToUser', ['json' => $body, 'headers' => $headers]); } } catch (Throwable $t) { Log::error('-------- User notification not sent-----------'); Log::error($t->getMessage() . '\n' . $t->getTraceAsString()); } } }