This commit is contained in:
候学杰 2019-01-29 14:35:24 +08:00
parent cb72a026e7
commit 2f4654d02a
2 changed files with 41 additions and 3 deletions

View File

@ -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'),
],

View File

@ -1 +1,39 @@
<?php
namespace Wechat\ServiceProvider;
use Illuminate\Support\ServiceProvider;
class WechatServiceProvider extends ServiceProvider
{
public function setupConfig()
{
$source = realpath(__DIR__ . '/../../config/wx.php');
if ($this->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);
});
}
}
}
}