Here's the latest documentation on Laravel 5.3 Notifications System:, (*1)
https://laravel.com/docs/master/notifications, (*2)
46Elks notification channel for Laravel
, (*3)
, (*4)
This package makes it easy to send notifications using 46Elks with Laravel 5.3., (*5)
46Elks has a whole bunch of phone oriented services. This package takes care of:
* SMS, (*6)
With more endpoints to come. Feel free to contribute., (*7)
Contents
Installation
composer require larsemil/46elks
Setting up the 46Elks service
add the following to your config/services.php, (*8)
'46elks' => [
'username' => env('FORTY_SIX_ELKS_USERNAME'),
'password' => env('FORTY_SIX_ELKS_PASSWORD'),
],
Also remember to update your .env with correct information:, (*9)
FORTY_SIX_ELKS_USERNAME=
FORTY_SIX_ELKS_PASSWORD=
You will find your username and password at https://46elks.se/account, (*10)
Usage
To use this channel simply create a notification that has the following content:, (*11)
public function via($notifiable)
{
return [FortySixElksChannel::class];
}
public function to46Elks($notifiable)
{
return (new FortySixElksSMS())
->line('Testsms')
->line('Olle')
->to('+46762216234')
->from('Emil');
}
Available mediums
SMS
The FortySixElksSMS have the following methods, all chainable., (*12)
Available Message methods for sms
from($mixed). Accepts a string up to 11 characters or number. Sms will be sent with that name., (*13)
to($number). International phone number., (*14)
line($string). Every string in a line will be on its own row., (*15)
flash(). Will set the message type to flash. Will not endup in sms inbox. See This tweet to find out how it looks on an iphone., (*16)
MMS
To use MMS simply use new FortySixElksMMS() instead of new FortySixElksSMS(), (*17)
The FortySixElksMMS have the following methods, all chainable., (*18)
Available Message methods
from($mixed). Accepts 'noreply' as a string or a MMS activated number, (*19)
to($number). International phone number., (*20)
line($string). Every string in a line will be on its own row., (*21)
image(). URL to the image to send in mms., (*22)
Error handling
How to handle notification send errors, (*23)
If for any reason there would be an error when sending a notification it will fire a
Illuminate\Notifications\Events\NotificationFailed event. You can then listen for that., (*24)
Example:, (*25)
Event::listen(NotificationFailed::class, function($event){
info('Error while sending sms');
});
And the event has $event->notifiable, $event->notification, $event->channel and $event->data(where you have the exception at $event->data['exception']), (*26)
Changelog
Please see CHANGELOG for more information what has changed recently., (*27)
Testing
bash
$ composer test, (*28)
Security
If you discover any security related issues, please email emil@dalnix.se instead of using the issue tracker., (*29)
Contributing
Please see CONTRIBUTING for details., (*30)
Credits
License
The MIT License (MIT). Please see License File for more information., (*31)