revosystems/paloma

This package is abandoned and no longer maintained. No replacement package was suggested.

Package to send Sms via Vonage/Nexmo


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Installation

You can install the package via composer:

composer require revosystems/paloma

You can publish and run the migrations with:

php artisan vendor:publish --tag="paloma-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="paloma-config"

This is the contents of the published config file:

return [
    'sms_from' => env('VONAGE_FROM_NUMBER', 'Vonage APIs'),
    'vonage_key' => env('VONAGE_KEY'),
    'vonage_secret' => env('VONAGE_SECRET'),
];

Usage

You can send sms directly using the facade or send sms using the notification feature from laravel.

To send sms directly:

use Revo\Paloma\Facades\Paloma;

Paloma::send(string $phone, string $message, string $service, ?string $from = null)

The phone must contain the country code prefix (34 or +34). A wrong phone will send anything. Vonage cannot validate the phone.

To notify using Paloma you should add the channel and method to your notification:

use Revo\Paloma\PalomaChannel;
use Revo\Paloma\PalomaMessage;

public function via($notifiable)
{
    return [PalomaChannel::class];
}

public function toPaloma($notifiable): PalomaMessage
{
    return new PalomaMessage(string $message, string $service, ?string $from = null);
}

Also the notifieble instance should have the $full_phone property. On a Laravel model can be a computed property as so:

public function getFullPhoneAttribute(): string
{
    return "34" . trim($this->phone);
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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