FeeController.php 1.1 KB
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/8
 * Time: 11:53
 */

namespace app\admin\controller;


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

class FeeController extends AdminBaseController
{
    public function index()
    {
        $id = $this->request->param('id', 1, 'intval');
        if ($this->request->isPost()) {
            $param = $this->request->param();
            $validate = new Validate([
                'fee'=>'require',
            ]);
            $validate->message([
                'fee'=>'服务费不能为空',
            ]);
            if (!$validate->check($param)) {
                $this->error($validate->getError());
            }
            Db::name('recyclefee')
                ->where('id', $id)
                ->update($param);
            $this->success('更新成功');
        } else {
            $data = Db::name('recyclefee')
                ->where('id', $id)
                ->find();
            $this->assign([
                'data' => $data,
            ]);
            return $this->fetch();
        }
    }
}