<?php

namespace app\admin\controller;

use app\admin\AdminBaseController;
use app\common\model\SettingModel;

class Setting extends AdminBaseController
{
    /**
     * 短信配置
     */
    public function sms()
    {
        $sms = SettingModel::getConfigValue(SettingModel::SMS);
        return view('', [
            'sms' => $sms,
        ]);
    }

    public function editSms()
    {
        $data = $this->_post(SettingModel::SMS);
        SettingModel::setConfigValue($data);
        ajax_return();
    }

    /**
     * 系统配置
     */
    public function system()
    {
        $system = SettingModel::getConfigValue(SettingModel::SMS);
        return view('', [
            'system' => $system,
        ]);
    }

    /**
     * 获取数据
     * @param array $param 要获取的数据
     * @return array
     */
    public function _post(array $param)
    {
        $res = [];
        foreach ($param as $v) {
            if (!empty(input($v))) {
                $res[$v] = input($v);
            }
        }

        return $res;
    }
}