diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..61ead86 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/vendor diff --git a/README.md b/README.md new file mode 100644 index 0000000..6a25a34 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Package For 4jawaly Sms For Laravel \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..1a78fa7 --- /dev/null +++ b/composer.json @@ -0,0 +1,29 @@ +{ + "name": "mfrouh/4jawaly", + "description": "Package For 4jawaly Sms For Laravel", + "type": "library", + "license": "MIT", + "autoload": { + "psr-4": { + "Mfrouh\\Sms4jawaly\\": "src/" + } + }, + "authors": [ + { + "name": "mfrouh", + "email": "mohamedfrouh96@gmail.com" + } + ], + "extra": { + "laravel": { + "providers": [ + "MFrouh\\Sms4jawaly\\Providers\\Sms4JawalyServiceProvider" + ] + }, + "aliases": { + "Sms4jawaly": "MFrouh\\Sms4jawaly\\Facades\\Sms4jawaly" + } + }, + "minimum-stability": "dev", + "require": {} +} diff --git a/src/BaseClass.php b/src/BaseClass.php new file mode 100644 index 0000000..ed3a39c --- /dev/null +++ b/src/BaseClass.php @@ -0,0 +1,58 @@ + config('sms4jawaly.username'), + 'password' => config('sms4jawaly.password'), + 'return' => 'json' + ]; + + $response = Http::get(self::Base_Url . '/getbalance.php', $data); + + return ['status' => true, 'response' => $response->currentuserpoints, 'message' => $response->MessageIs]; + } catch (Exception $error) { + return ['status' => false, 'response' => $error, 'message' => 'error']; + } + } + + public function sendSms($message, $phoneNumber) + { + try { + $data = [ + 'username' => config('sms4jawaly.username'), + 'password' => config('sms4jawaly.password'), + "message" => urlencode($message), + "numbers" => $this->convertArabicNumbers(ltrim($phoneNumber, '0')), + "sender" => config('sms4jawaly.sender_name'), + "unicode" => 'e', + 'return' => 'json' + ]; + + $response = Http::get(self::Base_Url . '/sendsms.php', $data); + + return $response; + } catch (Exception $error) { + return $error; + } + } + + private function convertArabicNumbers($number) + { + $arabic = ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩']; + + $english = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + + return str_replace($arabic, $english, $number); + } +} diff --git a/src/Facades/4Jawaly.php b/src/Facades/4Jawaly.php new file mode 100644 index 0000000..dae922b --- /dev/null +++ b/src/Facades/4Jawaly.php @@ -0,0 +1,14 @@ +app->bind('Sms4jawaly', function ($app) { + return new BaseClass(); + }); + } + + public function boot() + { + + } +} \ No newline at end of file diff --git a/src/config/sms4jawaly.php b/src/config/sms4jawaly.php new file mode 100644 index 0000000..eee1343 --- /dev/null +++ b/src/config/sms4jawaly.php @@ -0,0 +1,7 @@ + env('4JAWALY_USERNAME'), + 'password' => env('4JAWALY_PASSWORD'), + 'sender_name' => env('4JAWALY_SENDER_NAME') +];