coreproc/laravel-notification-channel-globe-labs-sms

This package makes it easy to send notifications using Globe Labs SMS with Laravel 5.3, 5.4, and 5.5

0.3.0 2018-08-01 02:40 UTC

This package is auto-updated.

Last update: 2021-11-12 00:45:54 UTC


README

Latest Version on Packagist Software License StyleCI SensioLabsInsight Quality Score Total Downloads

This package makes it easy to send notifications using Globe Labs SMS with Laravel 5.3 and above.

Contents

Installation

Install this package with Composer:

composer require coreproc/laravel-notification-channel-globe-labs-sms

Register the ServiceProvider in your config/app.php (Skip this step if you are using Laravel 5.5 and above):

Coreproc\GlobeLabsSms\GlobeLabsSmsServiceProvider::class,

Setting up the Globe Labs Sms service

Start by creating a project here: http://www.globelabs.com.ph/#!/developer/api/sms

Please note that this package does not handle the opt-in steps required for a user to subscribe to your Globe Labs SMS application.

This package assumes that you have the opt-in steps handled either via SMS or through a web form and that you already have access to the subscriber's access token.

Once you've registered and set up your app, add the short code to your configuration in config/broadcasting.php

'connections' => [
    ....
    'globe_labs_sms' => [
        'short_code' => env('GLOBE_LABS_SMS_SHORT_CODE'),
    ],
    ...
]

Usage

Set a routeNotificationForGlobeLabsSms() method in your model/class with the Notifiable trait. For example:

class User extends Model
{
    use Notifiable;

    public function routeNotificationForGlobeLabsSms()
    {
        return [
            'access_token' => 'access-token-obtained-from-sms-opt-in-this-could-be-stored-in-your-database',
            'address' => '09171234567', // can be any format as long as it is a valid mobile number
        ];
    }
}

You can now send SMS via Globe Labs by creating an GlobeLabsSmsMessage in a Notification class:

class AccountActivated extends Notification
{
    public function via($notifiable)
    {
        return [GlobeLabsSmsChannel::class];
    }

    public function toGlobeLabsSms($notifiable) 
    {
        return GlobeLabsSmsMessage::create($notifiable)
            ->setMessage('This is a test message');
    }
}

Call the SMS notification by calling the notify() method in the model/class. For example:

$user = User::find(1);

$user->notify(new AccountActivated);

Security

If you discover any security related issues, please email chris.bautista@coreproc.ph instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.