A collections of notification channels and senders
carropublic/notifications is a Laravel package for a collections of notification channels and senders.
It currently has 0 GitHub stars and 44.751 downloads on Packagist (latest version 1.4.3).
Install it with composer require carropublic/notifications.
Discover more Laravel packages by carropublic
or browse all Laravel packages to compare alternatives.
Last updated
Via Composer
$ composer require carropublic/notifications
Run the following vendor publish to publish Twillo config.
php artisan vendor:publish --provider="CarroPublic\Notifications\NotificationServiceProvider"
The following is the example usage of the package with Laravel's Notification.
class ExampleNotification extends Notification
{
// Which channel this notification should be sent to
public function via($notifiable)
{
return [ SMSChannel::class, WhatsAppChannel::class ];
}
// Notification payload (content) will be sent
public function toSMS($notifiable)
{
return new LaravelTwilioMessage("Message Content");
}
// Notification payload (content) will be sent
public function toWhatsApp($notifiable)
{
return new LaravelTwilioMessage("Message Content");
}
}
class Contact extends Model {
use Notifiable;
// Phone number to receive
public function routeNotificationForSms()
{
return $this->phone;
}
// Phone number to receive
public function routeNotificationForWhatsapp()
{
return $this->phone;
}
}
$contact->notify(new ExampleNotification());
Notification::route('sms')->notify(new ExampleNotification());
\CarroPublic\Notifications\Senders\Sender::registerSandboxValidatorExample:
Sender::registerSandboxValidator(function () {
return !is_production();
});
NOTIFICATION_SANDBOX_ENABLE to determine if running in sandbox mode. Default false⛔️ Notes: If the closure is registered, the env will be ignored
\CarroPublic\Notifications\Senders\Sender::registerValidForSandbox$to: the recipient the message will be sent to $type: the sender class
LaravelTwilioSender::registerValidPhoneForSandbox(function ($to, $type) {
switch ($type) {
case LineSender::class:
return true;
case TwilioSender::class:
return false;
}
}
Please see the changelog for more information on what has changed recently.
If you discover any security related issues, please email author email instead of using the issue tracker.
Please see the license file for more information.