ClockModel.php
934 字节
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
<?php
namespace api\common\model;
use think\Model;
class ClockModel extends Model
{
protected $name = 'clock';
protected $append = [
'status_text',
'user_start_text',
'user_end_text',
];
public function getStatusTextAttr($value,$data)
{
$status = [0=>'未打卡',1=>'已开始',2=>'完成打卡',3=>'未完成'];
return $status[$data['status']];
}
public function getUserStartTextAttr($value,$data){
if (empty($data['user_start'])){
return '';
}
return date('H:i',$data['user_start']);
}
public function getUserEndTextAttr($value,$data){
if (empty($data['user_end'])){
return '';
}
return date('H:i',$data['user_end']);
}
public function activity()
{
return $this->belongsTo('ActivityModel', 'activity_id', 'id', [], 'LEFT')->setEagerlyType(1);
}
}