定制 terranc/laravel-wechat-notification-channel 二次开发

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

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

terranc/laravel-wechat-notification-channel

Composer 安装命令:

composer require terranc/laravel-wechat-notification-channel

包简介

This is a Laravel expansion for the wechat Push.

README 文档

README

Packagist Total Downloads

适用于 Laravel 的微信模板消息推送通道适配器

该扩展是对 安正超 超哥的微信扩展的补充。

安装

composer require "larva/laravel-wechat-notification-channel"

配置

无需配置

使用

编写如下 通知类然后发出去就行了

namespace App\Models;

class User {
    public function routeNotificationForWechat(){
        return $this->wechatid;
    }
    
    public function routeNotificationForWechatMiniProgram(){
        return $this->wechatminiid;
    }

    public function routeNotificationForWechatSubscribe(){
        return $this->wechatminiid;
        // or
        // $notifiable->routeNotificationFor('wechatMiniProgram',$this) 通过小程序获取 不再设置此方法
    }
}
namespace App\Notifications;

use Illuminate\Notifications\Notification;

class WelcomeNotification extends Notification
{
    /**
     * Get the notification's channels.
     *
     * @param mixed $notifiable
     * @return array|string
     */
    public function via($notifiable)
    {
        return ['wechat','wechatMiniProgram'];
    }

    /**
     * Build the wechat representation of the notification.
     *
     * @param mixed $notifiable
     * @return array|false
     */
    public function toWechat($notifiable)
    {
        if (!$toUser = $notifiable->routeNotificationFor('wechat',$this)) {
            return false;
        }
        return [
            'touser' => $toUser,
            'template_id' => 'template-id',
            'page' => 'index',
            'form_id' => 'form-id',
            'data' => [
               'keyword1' => 'VALUE',
               'keyword2' => 'VALUE2',
                    // ...
            ],
        ];
    }
    
    /**
     * Build the MiniProgram representation of the notification.
     *
     * @param mixed $notifiable
     * @return array|false
     */
    public function toWechatMiniProgram($notifiable)
    {
        if (!$toUser = $notifiable->routeNotificationFor('wechatMiniProgram',$this)) {
            return false;
        }
        return [
            'touser' => $toUser,
            'template_id' => 'template-id',
            'page' => 'index',
            'form_id' => 'form-id',
            'data' => [
               'keyword1' => 'VALUE',
               'keyword2' => 'VALUE2',
                   // ...
            ],
        ];
    }

    /**
     * Build the WechatSubscribeChannel representation of the notification.
     *
     * @param mixed $notifiable
     * @return array|false
     */
    public function toWechatSubscribe($notifiable)
    {
        if (!$toUser = $notifiable->routeNotificationFor('wechatSubscribe',$this)) {
            return false;
        }
        return [
            'touser' => $toUser,
            'template_id' => 'template-id',
            'page' => 'pages/index/index',
            'miniprogram_state' => env('APP_DEBUG', false) ? 'trial' : 'formal',
            // 跳转小程序类型:developer 为开发版;trial为体验版;formal为正式版;默认为正式版
            'data' => [
                'name1' => 'name1',
                'thing2' => 'thing2',
                //...
            ],

        ];
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固