This package makes it easy to send notifications via AfricasTalking with Laravel
appslabke/laravel-notification-channels-africastalking is a Laravel package for this package makes it easy to send notifications via africastalking with laravel.
It currently has 0 GitHub stars and 128 downloads on Packagist (latest version v2.4.1).
Install it with composer require appslabke/laravel-notification-channels-africastalking.
Discover more Laravel packages by appslabke
or browse all Laravel packages to compare alternatives.
Last updated
This package makes it easy to send notifications using AfricasTalking with Laravel.
This package is part of the Laravel Notification Channels project. It provides additional Laravel Notification channels to the ones given by Laravel itself.
The AfricasTalking channel makes it possible to send out Laravel notifications as a SMS using AfricasTalking API.
You can install this package via composer:
composer require laravel-notification-channels/africastalking
The service provider gets loaded automatically.
You will need to Register and then go to your sandbox app Go To SandBox App. Click on settings Within this page, you will generate your Username and key. Place them inside your .env file. Remember to add your Sender ID that you will be using to send the messages.
AT_USERNAME=""
AT_KEY=""
AT_FROM=""
To load them, add this to your config/services.php . This will load the AfricasTalking data from the .env file.file:
'africastalking' => [
'username' => env('AT_USERNAME'),
'key' => env('AT_KEY'),
'from' => env('AT_FROM'),
]
Add the routeNotifcationForAfricasTalking method on your notifiable Model. If this is not added,
the phone_number 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 routeNotificationForAfricasTalking($notification)
{
return $this->phone;
}
}
To use this package, you need to create a notification class, like NewsWasPublished from the example below, in your Laravel application. Make sure to check out Laravel's documentation for this process.
<?php
use NotificationChannels\AfricasTalking\AfricasTalkingChannel;
use NotificationChannels\AfricasTalking\AfricasTalkingMessage;
class NewsWasPublished extends Notification
{
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return [AfricasTalkingChannel::class];
}
public function toAfricasTalking($notifiable)
{
return (new AfricasTalkingMessage())
->content('Your SMS message content');
}
}
$ composer test
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.
Leave a star and follow me on Twitter .