ClockModel.php 934 字节
<?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);
    }

}