Skip to content

osenco/laravel-bongasms

Repository files navigation

BongaSMS notification channel for Laravel

Latest Version on Packagist Software License StyleCI Quality Score Total Downloads

This package makes it easy to send notifications using Bonga with Laravel.

Contents

About

This package is part of the Laravel Notification Channels project. It provides additional Laravel Notification channels to the ones given by Laravel itself.

The Bonga channel makes it possible to send out Laravel notifications as a SMS using Bonga API.

Installation

You can install this package via composer:

composer require laravel-notification-channels/bonga

The service provider gets loaded automatically.

Setting up the Bonga Service

You will need to Register and then go to your Developer Hub. On the right, Generate New Key/Secret Pair. Place your API credentias inside your .env file.

BONGA_CLIENT=""
BONGA_KEY=""
BONGA_SECRET=""
BONGA_SERVICE=""

To load them, add this to your config/services.php . This will load the Bonga data from the .env file.file:

'bonga' => [
    'client'        => env('BONGA_CLIENT'),
    'key'           => env('BONGA_KEY'),
    'secret'        => env('BONGA_SECRET'),
    'service'       => env('BONGA_SERVICE'),
]

Add the routeNotifcationForBonga method on your notifiable Model. If this is not added, the phone field will be automatically used.

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Notifiable;

    /**
     * Route notifications for the Africas Talking channel.
     *
     * @param  \Illuminate\Notifications\Notification  $notification
     * @return string
     */
    public function routeNotificationForBonga($notification)
    {
        return $this->phone;
    }
}

Usage

To use this package, you need to create a notification class, like SendOtp from the example below, in your Laravel application. Make sure to check out Laravel's documentation for this process.

<?php

use NotificationChannels\Bonga\BongaChannel;
use NotificationChannels\Bonga\BongaMessage;

class SendOtp extends Notification
{
    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [BongaChannel::class];
    }

    public function toBonga($notifiable)
    {
		return (new BongaMessage())
                    ->content('Your SMS message content');

    }
}

Testing

$ composer test

Security

If you discover any security-related issues, please email [email protected] 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.

About

BongaSMS Laravel Notifications Package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages