Dairy.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
81
82
83
84
85
86
87
88
89
90
91
<?php
namespace app\admin\model\reservoir\run;
use think\Model;
class Dairy extends Model
{
// 表名
protected $name = 'reservoir_run_dairy';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'weather_text',
'safe_text',
'report_text',
'deal_text'
];
public function getWeatherList()
{
return ['1' => __('Weather 1'), '2' => __('Weather 2')];
}
public function getSafeList()
{
return ['1' => __('Safe 1'), '2' => __('Safe 2'), '3' => __('Safe 3'), '4' => __('Safe 4')];
}
public function getReportList()
{
return ['1' => __('Report 1'), '2' => __('Report 2'), '3' => __('Report 3')];
}
public function getDealList()
{
return ['1' => __('Deal 1'), '2' => __('Deal 2'), '3' => __('Deal 3')];
}
public function getWeatherTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['weather']) ? $data['weather'] : '');
$list = $this->getWeatherList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getSafeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['safe']) ? $data['safe'] : '');
$list = $this->getSafeList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getReportTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['report']) ? $data['report'] : '');
$list = $this->getReportList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getDealTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['deal']) ? $data['deal'] : '');
$list = $this->getDealList();
return isset($list[$value]) ? $list[$value] : '';
}
}