diff --git a/src/config.php b/config/wx.php similarity index 73% rename from src/config.php rename to config/wx.php index ae0cb6a..0ec8b19 100644 --- a/src/config.php +++ b/config/wx.php @@ -5,10 +5,10 @@ return [ */ 'work' => [ //企业ID - 'corp_id' => '', + 'corp_id' => env('WECHAT_WORK_CORP_ID'), //企业内各个应用的 secrets 'secrets' => [ - 'auth' => '', + 'miniprogram' => env('WECHAT_WORK_SECRET_MINIPROGRAM'), 'contact' => env('WECHAT_WORK_SECRET_CONTACT'), 'external_contact' => env('WECHAT_WORK_SECRET_EXTERNAL_CONTACT'), ], diff --git a/src/Wechat/ServerProvider/WechatServiceProvider.php b/src/Wechat/ServerProvider/WechatServiceProvider.php index a814366..6e50a7d 100644 --- a/src/Wechat/ServerProvider/WechatServiceProvider.php +++ b/src/Wechat/ServerProvider/WechatServiceProvider.php @@ -1 +1,39 @@ -app instanceof LaravelApplication && $this->app->runningInConsole()) { + $this->publishes([$source => config_path('wx.php')], 'wx'); + } elseif ($this->app instanceof LumenApplication) { + $this->app->configure('wx'); + } + + $this->mergeConfigFrom($source, 'rpc'); + } + + public function register() + { + $config = config['wx']; + + if (isset($config['work'])) { + + foreach ($config['work']['secrets'] as $key => $item) { + $this->app->singleton('wx.work.' . $key, function () { + return new ucwords($key); + }); + } + + } + + + } +} \ No newline at end of file