ManageController.php 1.8 KB
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
namespace app\admin\controller;

use cmf\controller\AdminBaseController;
use think\Db;
use app\admin\model\AdminMenuModel;
use think\Validate;

class ManageController extends AdminBaseController
{
    public function index(){
        $data=Db::name('manage')
            ->where('id',1)
            ->paginate(10);
        $this->assign([
            'data'=>$data,
            'page'=>$data->render(),
        ]);
        return $this->fetch();
    }
    //编辑
    public function edit(){
        $id=$this->request->param('id', 0, 'intval');
        if($this->request->isPost()){
            $param=$this->request->param();
            $validate = new Validate([
                'thumbnail' => 'require',
                'content' => 'require',
            ]);
            $validate->message([
                'thumbnail'=>'请上传缩略图!',
                'content' => '请输入页面内容!',
            ]);
            if (!$validate->check($param)) {
                $this->error($validate->getError());
            }
            $param['update_time']=time();
            Db::name('manage')
                ->where('id',$id)
                ->update($param);
            $this->success('更新成功!');
        }else{
            $data=Db::name('manage')
                ->where("id",$id)
                ->find();
            $this->assign([
                'data'=>$data,
            ]);
            return $this->fetch();
        }
    }
}