AdminContactController.php 1.5 KB
<?php
// +----------------------------------------------------------------------
// | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2019 http://www.thinkcmf.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 小夏 < 449134904@qq.com>
// +----------------------------------------------------------------------
namespace app\portal\controller;

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

class AdminContactController extends AdminBaseController
{
    //联系我们

    //编辑页面
    public function edit(){
        $contactModel = new ContactModel();
        $post = $contactModel->where('id',1)->find();
        $this->assign('post',$post);
        return $this->fetch();
    }

    //编辑提交
    public function editPost(){
        $data = $this->request->param();
        $result = $this->validate($data, 'AdminContact.edit');
        if ($result !== true) {
            $this->error($result);
        }
        $contactModel = new ContactModel();
        // 显式指定更新数据操作
        $res = $contactModel->isUpdate(true)->save($data);
        if($res){
            $this->success('保存成功!');
        }else{
            $this->error('失败');
        }
    }
}