revosystems/paloma

Package to send Sms via Vonage/Nexmo

0.1.4 2022-09-01 14:04 UTC

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('NEXMO_FROM_NUMBER', 'Vonage APIs'),
];

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)

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.