This package makes it easy to send notifications using textmagic with Laravel 5.3.
You can install the package via composer:
composer require laravel-notification-channels/textmagic
You must install the service provider:
// config/app.php
'providers' => [
...
NotificationChannels\TextMagic\TextMagicServiceProvider::class,
],
Create account inTextMagic and than create api key.
Then, configure your TextMagic api key and username:
// config/services.php
...
'textmagic' => [
'api_key' => env('TEXTMAGIC_API_KEY'),
'username' => env('TEXTMAGIC_USERNAME'),
],
...
You can now use the channel in your via()
method inside the Notification class.
namespace App\Notifications;
use Illuminate\Notifications\Notification;
use NotificationChannels\TextMagic\TextMagicChannel;
use NotificationChannels\TextMagic\TextMagicMessage;
class InvoicePaid extends Notification
{
public function via($notifiable)
{
return [TextMagicChannel::class];
}
public function toTextMagic($notifiable)
{
return (new TextMagicMessage())
->content('One of your invoices has been paid!');
}
}
After message sent MessageWasSent
event fired.
You can either send the notification by providing with the chat id of the recipient to the to($phoneNumber)
method like shown in the above example or add a routeNotificationForTextMagic()
method in your notifiable model:
...
/**
* Route notifications for the TextMagic channel.
*
* @return string
*/
public function routeNotificationForTextMagic()
{
return $this->phone_number;
}
...
to($phoneNumber)
: (string|array) Recipient's phone numbers.content('')
: (string) Notification (sms) message.from($phoneNumber)
: (string) phone number or alphanumeric sender ID
Please see CHANGELOG for more information what has changed recently.
$ 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.