From 153cdc0ac1ca84bd03823334eecc179c6b029a0c Mon Sep 17 00:00:00 2001 From: Vignesh Gurusamy Date: Mon, 10 Dec 2018 08:51:09 +0530 Subject: [PATCH] Avoid using singleton sms manager which holds previous connection state --- src/Providers/SmsServiceProvider.php | 2 +- src/SmsManager.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Providers/SmsServiceProvider.php b/src/Providers/SmsServiceProvider.php index e47b8cb..deae8bc 100644 --- a/src/Providers/SmsServiceProvider.php +++ b/src/Providers/SmsServiceProvider.php @@ -33,7 +33,7 @@ public function boot() */ public function register() { - $this->app->singleton('sms', function ($app) { + $this->app->bind('sms', function ($app) { return new SmsManager($app['config']['sms']); }); } diff --git a/src/SmsManager.php b/src/SmsManager.php index 4f6e3e7..abaed13 100644 --- a/src/SmsManager.php +++ b/src/SmsManager.php @@ -112,9 +112,9 @@ public function dispatch(): ResponseInterface throw MessageException::notFound(); } - $this->connection = $this->connection ?? $this->resolveConnection($this->device); + $connection = $this->connection ?? $this->resolveConnection($this->device); - return $this->getAdapter($this->connection)->send($this->device, $this->message); + return $this->getAdapter($connection)->send($this->device, $this->message); } /**