DoorController.php
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?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());
}
}
}