AgreementController.php 1.5 KB
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/1/28
 * Time: 10:02
 */

namespace app\admin\controller;


use cmf\controller\AdminBaseController;
use think\Db;
use think\Validate;

class AgreementController extends AdminBaseController
{
    public function index(){
        $data1=Db::name('page_html')->where('id',7)->whereOr('id',8)->select();
        $id = $this->request->param('id') ? $this->request->param('id') : $data1[0]['id'];
        $data=Db::name('page_html')
            ->where('id',$id)
            ->find();
        $this->assign([
            'data'=>$data,
            'data1'=>$data1,
            'id'=>$id,
        ]);
        return $this->fetch();
    }
    //编辑
    public function edit(){
        $id=$this->request->param('id', 0, 'intval');
        if($this->request->isPost()){
            $param=$this->request->param();
            $validate = new Validate([
                'title' => 'require',
                'content' => 'require',
            ]);
            $validate->message([
                'title' => '协议类型不能为空!',
                'content' => '协议内容不能为空!',
            ]);
            if (!$validate->check($param)) {
                $this->error($validate->getError());
            }
            $param['update_time']=time();
            Db::name('page_html')
                ->where('id',$id)
                ->update($param);
            $this->success('更新成功!');
        }else{

        }
    }
}