PHP code example of luisdalmolin / laravel-zenvia-channel

1. Go to this page and download the library: Download luisdalmolin/laravel-zenvia-channel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

luisdalmolin / laravel-zenvia-channel example snippets


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

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

...
/**
 * Route notifications for the Telegram channel.
 *
 * @return int
 */
public function routeNotificationForZenvia()
{
    return $this->phone;
}
...
 php
use NotificationChannels\Zenvia\ZenviaChannel;
use NotificationChannels\Zenvia\ZenviaMessage;
use Illuminate\Notifications\Notification;

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

    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');
    }
}