| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 | 
							- <?php
 
- namespace app\admin\model;
 
- use think\Model;
 
- class Tasklog extends Model
 
- {
 
-     
 
-     
 
-     // 表名
 
-     protected $name = 'task_log';
 
-     
 
-     // 自动写入时间戳字段
 
-     protected $autoWriteTimestamp = 'int';
 
-     // 定义时间戳字段名
 
-     protected $createTime = 'createtime';
 
-     protected $updateTime = 'updatetime';
 
-     protected $deleteTime = false;
 
-     // 追加属性
 
-     protected $append = [
 
-         'is_finish_text',
 
-         'is_reward_text',
 
-         'finish_time_text'
 
-     ];
 
-     
 
-     
 
-     public function getIsFinishList()
 
-     {
 
-         return ['1' => __('Is_finish 1'), '0' => __('Is_finish 0')];
 
-     }
 
-     public function getIsRewardList()
 
-     {
 
-         return ['1' => __('Is_reward 1'), '0' => __('Is_reward 0')];
 
-     }
 
-     public function getIsFinishTextAttr($value, $data)
 
-     {
 
-         $value = $value ? $value : (isset($data['is_finish']) ? $data['is_finish'] : '');
 
-         $list = $this->getIsFinishList();
 
-         return isset($list[$value]) ? $list[$value] : '';
 
-     }
 
-     public function getIsRewardTextAttr($value, $data)
 
-     {
 
-         $value = $value ? $value : (isset($data['is_reward']) ? $data['is_reward'] : '');
 
-         $list = $this->getIsRewardList();
 
-         return isset($list[$value]) ? $list[$value] : '';
 
-     }
 
-     public function getFinishTimeTextAttr($value, $data)
 
-     {
 
-         $value = $value ? $value : (isset($data['finish_time']) ? $data['finish_time'] : '');
 
-         return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
 
-     }
 
-     protected function setFinishTimeAttr($value)
 
-     {
 
-         return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
 
-     }
 
-     public function user()
 
-     {
 
-         return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
 
-     }
 
-     public function task()
 
-     {
 
-         return $this->belongsTo('Task', 'task_id', 'id', [], 'LEFT')->setEagerlyType(0);
 
-     }
 
- }
 
 
  |