Skip to content

fgrep/tww-sms-laravel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TWW Notifications Channel for Laravel 5.3+

Latest Version on Packagist Software License Total Downloads

This package makes it easy to send TWW SMS messages using TWW Webservice with Laravel 5.3+.

Contents

Installation

You can install the package via composer:

composer require fgrep/tww-sms-laravel

You must install the service provider (only required on Laravel 5.4 or lower):

// config/app.php
'providers' => [
    ...
    NotificationChannels\Zenvia\ZenviaServiceProvider::class,
],

Configuration

Configure your credentials:

// config/services.php
...
'tww' => [
    'from'    => env('TWW_FROM', 'Laravel Notification Channels'),
    'pretend' => env('TWW_PRETEND', false),
    'conta'   => env('TWW_CONTA', 'YOUR ACCOUNT'),
    'senha'   => env('TWW_SENHA', 'YOUR PASSWORD')
],
...

Usage

You can now use the channel in your via() method inside the Notification class.

use NotificationChannels\Tww\TwwChannel;
use NotificationChannels\Zenvia\TwwMessage;
use Illuminate\Notifications\Notification;

class InvoicePaid extends Notification
{
    public function via($notifiable)
    {
        return [TwwChannel::class];
    }

    public function toTww($notifiable)
    {
        return TwwMessage::create()
            ->from('Laravel') // optional
            ->to($notifiable->phone) // your user phone
            ->content('Your invoice has been paid')
            ->id('your-sms-id');
    }
}

Routing a message

You can either send the notification by providing with the chat id of the recipient to the to($phone) method like shown in the above example or add a routeNotificationForTww() method in your notifiable model:

...
/**
 * Route notifications for the Telegram channel.
 *
 * @return int
 */
public function routeNotificationForTww()
{
    return $this->phone;
}
...

Available Message methods

  • to($phone): (integer) Recipient's phone.
  • content('message'): (string) SMS message.
  • from('Sender'): (string) Sender's name.
  • id('sms-id'): (string) SMS 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

TWW SMS Notification Channel for Laravel

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages