From 2054d5e749fab63221590a4c3bfe76af81bc31f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Thu, 25 Nov 2021 11:08:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9F=AD=E4=BF=A1=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E7=A0=81=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Notifications/Channels/SmsChannel.php | 13 +++---------- app/Notifications/Messages/SmsMessage.php | 9 +++++++++ app/Notifications/SmsCodeCreated.php | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 app/Notifications/Messages/SmsMessage.php diff --git a/app/Notifications/Channels/SmsChannel.php b/app/Notifications/Channels/SmsChannel.php index 5dc2c034..b20a111b 100644 --- a/app/Notifications/Channels/SmsChannel.php +++ b/app/Notifications/Channels/SmsChannel.php @@ -2,10 +2,9 @@ namespace App\Notifications\Channels; +use App\Notifications\Messages\SmsMessage; use Illuminate\Notifications\Notification; use Overtrue\EasySms\EasySms; -use Overtrue\EasySms\Exceptions\NoGatewayAvailableException; -use Overtrue\EasySms\Message; class SmsChannel { @@ -27,16 +26,10 @@ class SmsChannel $message = $notification->toSms($notifiable); $phone = $notifiable->routeNotificationFor('sms', $notification); - if (! $phone && ! $message instanceof Message) { + if (! $phone && ! $message instanceof SmsMessage) { return; } - try { - $this->easySms->send($phone, $message); - } catch (NoGatewayAvailableException $e) { - foreach ($e->getExceptions() as $exception) { - report($exception); - } - } + $this->easySms->send($phone, $message); } } diff --git a/app/Notifications/Messages/SmsMessage.php b/app/Notifications/Messages/SmsMessage.php new file mode 100644 index 00000000..d0868cf4 --- /dev/null +++ b/app/Notifications/Messages/SmsMessage.php @@ -0,0 +1,9 @@ +