SettingController.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace addons\RealAuth\backend\controllers;
  3. use common\enums\AddonsEnum;
  4. use Yii;
  5. /**
  6. * 设置控制器
  7. *
  8. * Class SettingController
  9. * @package addons\RealAuth\backend\controllers
  10. */
  11. class SettingController extends BaseController
  12. {
  13. public $enableCsrfValidation = false;
  14. /**
  15. * 设置首页
  16. *
  17. * @return void
  18. */
  19. public function actionIndex()
  20. {
  21. if ($this->request->isAjax) {
  22. $conf = Yii::$app->services->setting->addons->get($this->mall_id, AddonsEnum::ADDONS_NAME_REAL_AUTH, 'basic');
  23. return $this->success('ok', $conf);
  24. }
  25. return $this->render('index');
  26. }
  27. /**
  28. * 保存设置
  29. *
  30. * @return void
  31. */
  32. public function actionSave()
  33. {
  34. if ($this->request->isPost) {
  35. // 数据提交
  36. $post = $this->request->post();
  37. $config = $post;
  38. $res = \Yii::$app->services->setting->addons->set($this->mall_id, AddonsEnum::ADDONS_NAME_REAL_AUTH, ['basic' => $config]);
  39. if($res){
  40. return $this->success('success');
  41. }
  42. return $this->error('保存失败');
  43. }
  44. }
  45. }