AdminWebdataController.php 1.8 KB
<?php
/**
 * 网站配置
 * Author : xiaojie
 * DateTime: 2018/12/03 14:01
 */
namespace app\portal\controller;


use app\portal\model\WebdataModel;
use cmf\controller\AdminBaseController;

/**
 * Class AdminWebdataController
 * @package app\portal\controller
 * @adminMenuRoot(
 *     'name'   =>'网站配置',
 *     'action' =>'default',
 *     'parent' =>'',
 *     'display'=> true,
 *     'order'  => 30,
 *     'icon'   =>'th',
 *     'remark' =>'网站配置'
 * )
 */

class AdminWebdataController extends AdminBaseController
{
    /**
     * 展会倒计时
     * @adminMenu(
     *     'name'   => '展会倒计时',
     *     'parent' => 'portal/AdminWebdata/default',
     *     'display'=> true,
     *     'hasView'=> true,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '展会倒计时',
     *     'param'  => ''
     * )
     */
    public function index()
    {
        $webdataModel = new WebdataModel();
        $info = $webdataModel->where('id',1)->find();
        $info['start_time'] = date('Y-m-d',$info['start_time']);

        $this->assign('info',$info);
        return $this->fetch();
    }

    /**
     * 保存
     * @adminMenu(
     *     'name'   => '保存',
     *     'parent' => 'index',
     *     'display'=> false,
     *     'hasView'=> false,
     *     'order'  => 10000,
     *     'icon'   => '',
     *     'remark' => '保存',
     *     'param'  => ''
     * )
     */
    public function edit()
    {
        $webdataModel = new WebdataModel();
        $param = $this->request->param();
        $param['start_time'] = strtotime($param['start_time']);
        $res = $webdataModel->isUpdate(true)->save($param);
        if($res){
            $this->success('保存成功');
        }
        $this->error('请稍后重试');
    }

}