From f63c6d4c9a0b93fde41b80ace09393d4a849656a Mon Sep 17 00:00:00 2001 From: Ken Date: Sun, 15 May 2022 09:01:15 +0800 Subject: [PATCH] added Malaysia Mode enable for Malaysia user only. Other country please set your own full +[CountryCode] --- README.md | 1 + src/UltraSmsApi.php | 4 ++++ src/UltraSmsChannel.php | 20 ++++++++++++++------ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 58c0140..ab739da 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ Add your ultrasms instanceId and token to your `config/services.php`: 'ultrasms' => [ 'instanceId' => env('ULTRASMS_INSTANCEID'), 'token' => env('ULTRASMS_TOKEN'), + 'isMalaysiaMode' => env('ULTRASMS_MALAYSIA_MODE') ?? 0, 'isDebug' => env('ULTRASMS_DEBUG_ENABLE') ?? 0, 'debugReceiveNumber' => env('ULTRASMS_DEBUG_RECEIVE_NUMBER'), ], diff --git a/src/UltraSmsApi.php b/src/UltraSmsApi.php index 6cb7e80..88fe274 100644 --- a/src/UltraSmsApi.php +++ b/src/UltraSmsApi.php @@ -22,6 +22,9 @@ class UltraSmsApi /** @var string */ protected $token; + /** @var integer */ + public $isMalaysiaMode; + /** @var integer */ public $isDebug; @@ -41,6 +44,7 @@ public function __construct($config) $this->instanceId = $config['instanceId']; $this->token = $config['token']; + $this->isMalaysiaMode = $config['isMalaysiaMode']; $this->isDebug = $config['isDebug']; $this->debugReceiveNumber = $config['debugReceiveNumber']; diff --git a/src/UltraSmsChannel.php b/src/UltraSmsChannel.php index dc36df4..bb8be50 100644 --- a/src/UltraSmsChannel.php +++ b/src/UltraSmsChannel.php @@ -55,15 +55,23 @@ protected function sendMessage($recipient, UltraSmsMessage $message) } else { - //this is for malaysia number use case, other country kindly fork your version - if ($recipient[0] == '6') + if($this->ultrasms->isMalaysiaMode) { - $valid_mobile = '+' . $recipient; + //this is for malaysia number use case, + if ($recipient[0] == '6') + { + $valid_mobile = '+' . $recipient; + } + + if ($recipient[0] == '0') + { + $valid_mobile = '+6' . $recipient; + } } - - if ($recipient[0] == '0') + else { - $valid_mobile = '+6' . $recipient; + //please set +[CountryCode] + $valid_mobile = $recipient; } }