123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Maintain extends Model
- {
-
-
- // 表名
- protected $table = 'maintain';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'integer';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'status_text',
- 'canceltime_text',
- 'finishtime_text',
- 'baojia_confirmtime_text',
- 'cailiao_time_text',
- 'lingqu_time_text',
- 'shangmen_time_text',
- 'wancheng_time_text',
- 'eva_time_text'
- ];
-
-
- public function getStatusList()
- {
- return ['0' => __('Status 0'), '2' => __('Status 2'), '20' => __('Status 20'), '22' => __('Status 22'), '30' => __('Status 30'), '40' => __('Status 40'), '50' => __('Status 50'), '60' => __('Status 60'), '70' => __('Status 70'), '80' => __('Status 80'), '90' => __('Status 90'), '92' => __('Status 92'), '100' => __('Status 100')];
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getCanceltimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['canceltime']) ? $data['canceltime'] : '');
- 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 getBaojiaConfirmtimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['baojia_confirmtime']) ? $data['baojia_confirmtime'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getCailiaoTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['cailiao_time']) ? $data['cailiao_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getLingquTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['lingqu_time']) ? $data['lingqu_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getShangmenTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['shangmen_time']) ? $data['shangmen_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getWanchengTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['wancheng_time']) ? $data['wancheng_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getEvaTimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['eva_time']) ? $data['eva_time'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- protected function setCanceltimeAttr($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);
- }
- protected function setBaojiaConfirmtimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setCailiaoTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setLingquTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setShangmenTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setWanchengTimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setEvaTimeAttr($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 user()
- {
- return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function usercompany()
- {
- return $this->belongsTo('Usercompany', 'uc_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- public function worker()
- {
- return $this->belongsTo('Worker', 'worker_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|