Prefix.php
2.67 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
namespace app\admin\model\kuerp;
use think\Model;
class Prefix extends Model
{
// 表名
protected $name = 'kuerp_prefix';
// 自动写入时间戳字段
protected $autoWriteTimestamp = false;
// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = false;
// 追加属性
protected $append = [
'year_text',
'month_text',
'day_text',
'hour_text',
'minute_text',
'second_text'
];
public function getYearList()
{
return ['1' => __('Year 1'), '2' => __('Year 2')];
}
public function getMonthList()
{
return ['1' => __('Month 1'), '2' => __('Month 2')];
}
public function getDayList()
{
return ['1' => __('Day 1'), '2' => __('Day 2')];
}
public function getHourList()
{
return ['1' => __('Hour 1'), '2' => __('Hour 2')];
}
public function getMinuteList()
{
return ['1' => __('Minute 1'), '2' => __('Minute 2')];
}
public function getSecondList()
{
return ['1' => __('Second 1'), '2' => __('Second 2')];
}
public function getYearTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['year']) ? $data['year'] : '');
$list = $this->getYearList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getMonthTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['month']) ? $data['month'] : '');
$list = $this->getMonthList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getDayTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['day']) ? $data['day'] : '');
$list = $this->getDayList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getHourTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['hour']) ? $data['hour'] : '');
$list = $this->getHourList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getMinuteTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['minute']) ? $data['minute'] : '');
$list = $this->getMinuteList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getSecondTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['second']) ? $data['second'] : '');
$list = $this->getSecondList();
return isset($list[$value]) ? $list[$value] : '';
}
}