| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace addons\SmartForm\backend\controllers;
- use Yii;
- use common\helpers\FormatHelper;
- use common\controllers\AddonsController;
- use common\enums\StatusEnum;
- use addons\SmartForm\common\models\AddonsSmartFormSetting; # 配置
- /**
- * 配置页
- *
- * Class SettingController
- * @package addons\SmartForm\backend\controllers
- */
- class SettingController extends BaseController
- {
-
- public $enableCsrfValidation = false;
- /**
- * 首页
- *
- * @return string
- */
- public function actionIndex()
- {
- try {
- $request = Yii::$app->request;
- if ($request->isAjax) {
- if ($request->isPost) {
- $post = Yii::$app->request->post();
- $post['mall_id'] = $this->mall_id;
-
- $status = AddonsSmartFormSetting::setData($post);
- if(!$status){
- Yii::error(AddonsSmartFormSetting::getStaticError());
- return $this->error(AddonsSmartFormSetting::getStaticError());
- }
- return $this->success('操作成功');
- }
- }else{
-
- return $this->render('index',[]);
- }
- } catch (\Exception $e) {
-
- $exception = FormatHelper::exception($e, "保存失败");
- Yii::error($exception);
- return $this->error($exception);
-
- }
-
- }
- /**
- * @method actionInfo
- * 获取配置明细
- * @author zqh
- * @datetime 2022-05-31T16:23:57+0800
- * @return [type] [description]
- */
- public function actionInfo()
- {
- try {
- $request = Yii::$app->request;
- if ($request->isAjax) {
- if ($request->isGet) {
- $where['mall_id'] = $this->mall_id;
- $where['status'] = StatusEnum::ENABLED;
- $find = AddonsSmartFormSetting::findOne($where,true);
- return $this->success('获取成功', $find);
- }
- }
- } catch (\Exception $e) {
-
- $exception = FormatHelper::exception($e, "获取失败");
- Yii::error($exception);
- return $this->error($exception);
-
- }
- }
- }
|