OfficeModel.php
2.0 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* Created by PhpStorm.
* auther: sgj
* Date: 2018/11/25
* Time: 17:04
*/
namespace app\admin\model;
use think\Model;
use traits\model\SoftDelete;
class OfficeModel extends Model
{
use SoftDelete;
protected $deleteTime = 'delete_time';
protected $insert =['addtime'];
/**
* 自动填充数据
* @return mixed
*/
protected function setAddtimeAttr()
{
return time();
}
/**
* 返回平台信息
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getHospital($platment=''){
if (empty($platment)){
$map['parent_id']='0';
$map['delete_time']='0';
$platment=db('hospital')->where($map)->select();
}else{
$platment=db('hospital')->where('id',$platment)->select();
}
return $platment;
}
/**
* 获取医院
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getOffice($hospital_id){
$map['hospital_id']=$hospital_id;
$office=$this->where($map)->select();
return $office;
}
/**
* 删除科室
* @param $office_id 科室id
* @return int
*/
public function officeDel($office_id){
$result=$this::destroy($office_id);
return $result;
}
public function officeAdd($id,$name,$platform){
$this->data([
'name' => $name,
'hospital_id' => $id,
'platform' => $platform
]);
return $this->save();
}
}