DoorController.php 1.2 KB
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/8
 * Time: 17:07
 */

namespace app\index\controller;

use cmf\controller\HomeBaseController;
use cmf\controller\RestBaseController;
use think\Db;
use think\Validate;

class DoorController extends HomeBaseController
{
    public function index()
    {
//        $id = $this->getUserID();
        $id = cmf_get_current_user_id();
        $where['delete_time'] = ['eq',0];
        $data = Db::name('recycle')
            ->where($where)
            ->select()
            ->toArray();
        $this->assign('data',$data);
        return $this->fetch();
    }

    public function add()
    {
        $param = $this->request->param();
        $param['create_time']=time();
        $validate = new Validate([
            'name'=>'require',
            'phone'=>'require|max:11',
            'address'=>'require'
        ]);
        $validate->message([
            'name'=>'姓名不能为空',
            'phone.require'=>'联系方式不能为空',
            'phone.max'=>'联系方式最多11位',
            'address'=>'详细地址不能为空'
        ]);
        if (!$validate->check($param)) {
            $this->error($validate->getError());
        }

    }
}