定制 carropublic/notifications 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

carropublic/notifications

最新稳定版本:1.4.2

Composer 安装命令:

composer require carropublic/notifications

包简介

A collections of notification channels and senders

README 文档

README

Latest Version on Packagist Total Downloads

Installation

Via Composer

$ composer require carropublic/notifications

Run the following vendor publish to publish Twillo config.

php artisan vendor:publish --provider="CarroPublic\Notifications\NotificationServiceProvider"

Usage

LaravelNotification

The following is the example usage of the package with Laravel's Notification.

Create Notification Class

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

Create Notifiable Class

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; } } 
Sending Notification from Notifiable Instance
$contact->notify(new ExampleNotification()); 
Sending Notification from Anonymous Notifiable Instance
Notification::route('sms')->notify(new ExampleNotification()); 

Sandbox Mode

How to enable SandBox Mode

  1. Register Closure to return if testing is enabled \CarroPublic\Notifications\Senders\Sender::registerSandboxValidator

Example:

Sender::registerSandboxValidator(function () { return !is_production(); }); 
  1. Otherwise, useNOTIFICATION_SANDBOX_ENABLE to determine if running in sandbox mode. Default false

⛔️ Notes: If the closure is registered, the env will be ignored

How to bypass sandbox validator

  • Register Closure to return if sandbox is enabled \CarroPublic\Notifications\Senders\Sender::registerValidForSandbox

$to: the recipient the message will be sent to $type: the sender class

  • LineSender
  • TelerivetSender
  • TwilioSender
  • MailChannel (Since there is not MailSender, the MailChannel will be used instead)
LaravelTwilioSender::registerValidPhoneForSandbox(function ($to, $type) { switch ($type) { case LineSender::class: return true; case TwilioSender::class: return false; } } 

Change log

Please see the changelog for more information on what has changed recently.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

Please see the license file for more information.

统计信息

  • 总下载量: 38.8k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固