1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Wentihuizong extends Model
- {
-
-
- // 表名
- protected $table = 'wentihuizong';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'findtime_text',
- 'finishtime_text',
- 'result_text'
- ];
-
-
- public function getResultList()
- {
- return ['1' => __('Result 1'), '2' => __('Result 2')];
- }
- public function getFindtimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['findtime']) ? $data['findtime'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getFinishtimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['finishtime']) ? $data['finishtime'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getResultTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['result']) ? $data['result'] : '');
- $list = $this->getResultList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- protected function setFindtimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setFinishtimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- public function company()
- {
- return $this->belongsTo('Company', 'company_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function usercompany()
- {
- return $this->belongsTo('Usercompany', 'uc_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|