ConfigController.php 920 B

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