Hardware.php
1.9 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
81
82
83
84
85
86
<?php
namespace app\admin\model\reservoir\hkws;
use think\Model;
class Hardware extends Model
{
// 表名
protected $name = 'reservoir_hkws_hardware';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'type_text',
'type_child_name_text'
];
public function getTypeList()
{
return ['1' => __('Type 1')];
}
public function getTypeChildNameList()
{
return ['1' => __('Type_child_name 1'), '2' => __('Type_child_name 2')];
}
public function getTypeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
$list = $this->getTypeList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getTypeChildNameTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['type_child_name']) ? $data['type_child_name'] : '');
$list = $this->getTypeChildNameList();
return isset($list[$value]) ? $list[$value] : '';
}
public function reservoirprovince()
{
return $this->belongsTo('app\admin\model\reservoir\Province', 'province_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function reservoirstate()
{
return $this->belongsTo('app\admin\model\reservoir\State', 'state_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function reservoircounty()
{
return $this->belongsTo('app\admin\model\reservoir\County', 'county_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function reservoirlist()
{
return $this->belongsTo('app\admin\model\reservoir\Reservoirlist', 'reservoir_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}