ConfigController.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace addons\Wechat\merchant\controllers;
  3. use Yii;
  4. use common\helpers\ArrayHelper;
  5. use addons\Wechat\merchant\forms\ConfigFrom;
  6. use addons\Wechat\merchant\forms\HistoryForm;
  7. /**
  8. * Class ConfigController
  9. * @package addons\Wechat\merchant\controllers
  10. * @author jianyan74 <751393839@qq.com>
  11. */
  12. class ConfigController extends BaseController
  13. {
  14. /**
  15. * 首页
  16. *
  17. * @return string
  18. */
  19. public function actionIndex()
  20. {
  21. $model = new ConfigFrom();
  22. $model->attributes = Yii::$app->services->config->backendConfigAll();
  23. $historyForm = new HistoryForm();
  24. $historyForm->attributes = Yii::$app->services->addonsConfig->getConfig();
  25. if ($model->load(Yii::$app->request->post()) && $historyForm->load(Yii::$app->request->post())) {
  26. // 基本信息
  27. Yii::$app->services->config->updateAll(Yii::$app->id, 0, ArrayHelper::toArray($model));
  28. // 插件信息
  29. Yii::$app->services->addonsConfig->setConfig(ArrayHelper::toArray($historyForm));
  30. return $this->message("保存成功", $this->redirect(Yii::$app->request->referrer));
  31. }
  32. return $this->render('index',[
  33. 'model' => $model,
  34. 'historyForm' => $historyForm
  35. ]);
  36. }
  37. }
粤ICP备19079148号