<?php

namespace frontend\modules\api\controllers;

use common\models\SearchConfig;
use frontend\modules\api\components\BaseAdminController;
use Yii;
use yii\web\Response;

class SearchConfigController extends BaseAdminController
{
    /**
     * 高级搜索显示配置
     * @return Response
     */
    public function actionInfo()
    {
        $id = 1;
        $SearchConfig = SearchConfig::findOne($id);
        //组合数据
        $data['data'] = json_decode($SearchConfig->content, true);
        return $this->asJson($data);
    }

    /**
     * 高级搜索显示配置修改
     * @return Response
     */
    public function actionUpdate()
    {
        $data = Yii::$app->request->post()["data"];
        $id = 1;
        $SearchConfig = SearchConfig::findOne($id);
        $SearchConfig->content = json_encode($data, true);
        $SearchConfig->update_time = time();
        $SearchConfig->save();
        return $this->asJson();
    }
}