• 适用于 Laravel 的微信通知渠道


    适用于 Laravel 的微信通知渠道

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

    安装

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

    配置

    无需配置

    使用

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

    namespace AppModels;
    
    class User {
        public function routeNotificationForWechat(){
            return $this->wechatid;
        }
        
        public function routeNotificationForWechatMiniProgram(){
            return $this->wechatminiid;
        }
    }
    
    namespace AppNotifications;
    
    use IlluminateNotificationsNotification;
    
    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',
                       // ...
                ],
            ];
        }
    }
    
  • 相关阅读:
    minio临时凭证 下载大文件合并UInt8Arrays
    elupload 传参
    [k8s] 创建sa类型的kubeconfig
    JAVA字符流写数据的五种方式 145
    JAVA copy多级目录文件
    JAVA线程实现的第二种方式
    JAVA 序列化类168
    JAVA 字符流复制JAVA文件 147
    JAVA UDP发送案例
    JAVA中多线程的数据安全问题
  • 原文地址:https://www.cnblogs.com/fyblzds/p/12780275.html
Copyright © 2020-2023  润新知