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',
                       // ...
                ],
            ];
        }
    }
    
  • 相关阅读:
    把安卓QQ浏览器下载的视频m3u8列表文件转成mp4格式(或者其它视频格式)
    Win8系统删除历史用户本地头像
    大叔郑州街头卖刀 这口才应该上春晚啊
    从尽力而为到全力以赴
    用虚假邮箱注册微博
    百度网盘总结
    试用Sublime Text 3
    玉米地烧毁,相关部门让找鸟儿去索赔
    Video Download Helper总结
    9.29
  • 原文地址:https://www.cnblogs.com/fyblzds/p/12780275.html
Copyright © 2011-2022 走看看