承接 deegitalbe/laravel-trustup-io-notifier 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

deegitalbe/laravel-trustup-io-notifier

最新稳定版本:v2.0.0

Composer 安装命令:

composer require deegitalbe/laravel-trustup-io-notifier

包简介

This is my package laravel-trustup-io-notifier

README 文档

README

Trustup Pro Notifier

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

Compatibility

Laravel Package
8.x / 9.x 1.x
12.x 2.x

Easily send notifications through a centralized notifier instance. Supports emails (Postmak), sms (Vonage/Nexmo), postal letters (Postbird) and push (FCM) via custom notification channels that are easy to use. A single app name and token are enough to use all these channels.

Installation

You can install the package via composer:

composer require deegitalbe/laravel-trustup-io-notifier

You can publish and run the migrations with:

php artisan vendor:publish --tag="laravel-trustup-io-notifier-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="laravel-trustup-io-notifier-config"

This is the contents of the published config file:

return [

    /**
     * Sets at which URL the notifier is accessible.
     * Default value: https://notifier.trustup.io
     */
    'url' => env('TPN_URL', 'https://notifier.trustup.io'),

    /**
     * App name (default, invoicing...).
     */
    'app' => env('TPN_APP_NAME', 'default'),

    /**
     * App key
     */
    'key' => env('TPN_APP_KEY')
];

Usage

<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class DemoNotification extends Notification implements ShouldQueue
{
    use Queueable;

    public $channels;

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return ['tpn_sms', 'tpn_email', 'tpn_letter', 'tpn_push', 'database'];
    }
    
    public function toTPNSMS($notifiable): array
    {
        return [
            'to' => '31657616867',
            'text' => 'This is a test SMS'
        ];
    }
    
    public function toTPNEmail($notifiable): array
    {
        return [
            'to' => 'florian.husquinet@deegital.be',
            'html' => '<h1>Demo notification</h1><p>This is my email content...</p>',
            'plain' => 'This is my email content...',
            'subject' => 'Demo notification',
            'headers' => [
                'X-Model-ID' => 1,
                'X-Model-Type' => 'user'
            ]
        ];
    }
    
    public function toTPNPush($notifiable): array
    {
        return [
            'to' => 'f0TAY_cMSpi2nNnakQ_B0w:APA91bFV1-2sblQS1h9mGn6I_aYJEZtww67fCJXN3Ir7V1179q7z_oHDLipQL1KAFs7meUyveVomzi2wLHTYuzXR7rDDnFiOBmCzGFEx-_aRszH0B2lIIelqzBjEjo5cL2t98bZc3B5g',
            'name' => 'demo-notification',
            'title' => 'Demo notification',
            'body' => 'Lorem ipsum...',
            'data' => [
                'type' => 'new-request',
                'id' => '555'
            ]
        ];
    }
    
    public function toTPNLetter($notifiable): array
    {
        return [
            'name' => 'demo-notification',
            'pdf' => 'https://trustup-dev-billing.ams3.digitaloceanspaces.com/202202-2263%20(5).pdf'
        ];
    }
    
    public function toArray($notifiable)
    {
        return [
            'channels' => $this->via($notifiable),
            'to' => '31657616867',
            'text' => 'This is a demo notification'
        ];
    }
}

What happens when you send a notification

The channel will make the API call to the notifier instance for each channel provided with a uuid that is generated then stored in the notification_log_uuids. You can then see how your notification behaved once it was send to the notifier by querying it using that uuid.
Notifications should be sent in queue from your app, as this is always the best possible use. Regardless of what you do in your own app, the notifier will accept the notification and send it to its own queue. There might be a delay of a few seconds before it is handled.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固