Skip to content

jozefbalun/textmagic

Repository files navigation

TextMagic Notifications Channel for Laravel 5.3

Latest Version on Packagist Software License Build Status StyleCI SensioLabsInsight Quality Score Code Coverage Total Downloads

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

Contents

Installation

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,
],

Setting up the TextMagic service

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'),
],
...

Usage

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.

Routing a message

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;
}
...

Available methods

  • to($phoneNumber): (string|array) Recipient's phone numbers.
  • content(''): (string) Notification (sms) message.
  • from($phoneNumber): (string) phone number or alphanumeric sender ID

Changelog

Please see CHANGELOG for more information what has changed recently.

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

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages