2017 © Pedro PelĂĄez
 

library laravel-zenvia-channel

Send SMS messages with Zenvia

image

luisdalmolin/laravel-zenvia-channel

Send SMS messages with Zenvia

  • Friday, June 1, 2018
  • by luisdalmolin
  • Repository
  • 1 Watchers
  • 6 Stars
  • 6,443 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 4 Versions
  • 14 % Grown

The README.md

Zenvia Notifications Channel for Laravel 5

Latest Version on Packagist Software License Total Downloads, (*1)

This package makes it easy to send Zenvia SMS messages using Zenvia API with Laravel 5., (*2)

Contents

Installation

You can install the package via composer:, (*3)

``` bash composer require luisdalmolin/laravel-zenvia-channel, (*4)


You must install the service provider: ```php // config/app.php 'providers' => [ ... NotificationChannels\Zenvia\ZenviaServiceProvider::class, ],

Configuration

Configure your credentials:, (*5)

// config/services.php
...
'zenvia' => [
    'from'    => env('ZENVIA_FROM', 'Laravel Notification Channels'),
    'pretend' => env('ZENVIA_PRETEND', false),
    'conta'   => env('ZENVIA_CONTA', 'YOUR ACCOUNT'),
    'senha'   => env('ZENVIA_SENHA', 'YOUR PASSWORD')
],
...

Usage

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

``` php use NotificationChannels\Zenvia\ZenviaChannel; use NotificationChannels\Zenvia\ZenviaMessage; use Illuminate\Notifications\Notification;, (*7)

class InvoicePaid extends Notification { public function via($notifiable) { return [ZenviaChannel::class]; }, (*8)

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

}, (*9)


### 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 routeNotificationForZenvia() method in your notifiable model: ```php ... /** * Route notifications for the Telegram channel. * * @return int */ public function routeNotificationForZenvia() { 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., (*10)

Testing

bash $ composer test, (*11)

Security

If you discover any security related issues, please email luis.nh@gmail.com instead of using the issue tracker., (*12)

Contributing

Please see CONTRIBUTING for details., (*13)

Credits

License

The MIT License (MIT). Please see License File for more information., (*14)

The Versions