zoukankan      html  css  js  c++  java
  • 适用于 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',
                       // ...
                ],
            ];
        }
    }
    
  • 相关阅读:
    【leetcode】N叉树的前序遍历
    【leetcode】第 N 个泰波那契数
    【leetcode】下一个更大元素 I
    【leetcode】Nim 游戏
    【leetcode】非递减数列
    053-208
    053-211
    053-56
    053-53
    053-236
  • 原文地址:https://www.cnblogs.com/fyblzds/p/12780275.html
Copyright © 2011-2022 走看看