An unofficial laravel package for SmartSMSSolutions' API-x. The Package that helps deliver SMS to phone numbers on Do Not Disturb (DND).
Below is the file structure of this package.
\---src
| APIx.php
| APIxMessage.php
| APIxServiceProvider.php
|
+---Channels
| SmartSMSChannel.php
|
+---Commands
| \---Log
| ClearCommand.php
| DisplayCommand.php
|
+---config
| api-x.php
|
+---Controllers
| LogController.php
|
+---Exceptions
| CouldNotSendNotification.php
| InvalidConfiguration.php
|
+---Facades
| APIxFacade.php
|
\---resources
\---views
log.blade.php
You can install the package via composer:
$ composer require abdulmatinsanni/api-x
Add the service provider (only required on Laravel 5.4 or lower):
// config/app.php
'providers' => [
...
AbdulmatinSanni\APIx\APIxServiceProvider::class,
],
'aliases' => [
'APIx' => AbdulmatinSanni\APIx\Facades\APIxFacade::class,
],
Add your API-x API Token (string), Log Message (boolean), Mock SMS (boolean) and Sender Name (optional|string) to your .env (environment) file:
SMARTSMSSOLUTIONS_API_TOKEN=apixtokenhere
SMARTSMSSOLUTIONS_LOG_MESSAGES=true
SMARTSMSSOLUTIONS_FAKE_SMS=true
SMARTSMSSOLUTIONS_SENDER_NAME=sendernamehere
Below is an example of API-x usage in controllers.
...
use APIx;
class SMSController extends Controller
{
public function send(Request $request)
{
$response = APIx::to($request->recipient)
->from($request->name)
->message($request->message)
->send();
return $response;
}
}
...
class User extends Model
{
use Notifiable;
public function routeNotificationForSmartSMS($notification)
{
return $this->phone_column;
}
}
...
use AbdulmatinSanni\APIx\APIxMessage;
use AbdulmatinSanni\APIx\Channels\SmartSMSChannel;
class DemoNotification extends Notification
{
use Queueable;
...
public function via($notifiable)
{
return [SmartSMSChannel::class];
}
...
public function toSmartSMS($notifiable)
{
return (new APIxMessage())
->from($this->from)
->message($this->message);
}
}
...
public class NotificationsController extends Controller
{
public function notify()
{
$user = User::firstOrFail();
$user->notify(new DemoNotification("SarahFound", "Hi, you are invited to our seminar!!!!!"));
}
}
to([])
: Accepts an array or string of recipients' phone number(s).from('')
: Accepts a phone to use as the sms sender.message('')
: Accepts a string value for the sms body.send()
: Does the sending of the sms. Can also accept a string which represent sms body if message('') was skipped.
Showing all entries of log:
$ php artisan api-x:log
Showing the last logged sms:
$ php artisan api-x:log --latest
Limiting the entries of log to be displayed:
$ php artisan api-x:log --limit={no_of_messages}
Clearing all entries of log:
$ php artisan api-x:log clear
Please see CHANGELOG for more information on what has changed recently.
$ composer test (NOT YET)
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.