123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Car extends Model
- {
-
-
- // 表名
- protected $table = 'car';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'chepaicolor_text',
- 'is_etc_text',
- 'power_text',
- 'zhucetime_text',
- 'leasetype_text'
- ];
-
-
- public function getChepaicolorList()
- {
- return ['5' => __('Chepaicolor 5'), '1' => __('Chepaicolor 1'), '2' => __('Chepaicolor 2'), '3' => __('Chepaicolor 3'), '4' => __('Chepaicolor 4'), '9' => __('Chepaicolor 9'), '91' => __('Chepaicolor 91'), '92' => __('Chepaicolor 92'), '94' => __('Chepaicolor 94'), '224' => __('Chepaicolor 224'), '225' => __('Chepaicolor 225')];
- }
- public function getIsEtcList()
- {
- return ['0' => __('Is_etc 0'), '1' => __('Is_etc 1')];
- }
- public function getPowerList()
- {
- return ['1' => __('Power 1'), '2' => __('Power 2')];
- }
- public function getLeasetypeList()
- {
- return ['1' => __('Leasetype 1'), '2' => __('Leasetype 2'), '3' => __('Leasetype 3')];
- }
- public function getChepaicolorTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['chepaicolor']) ? $data['chepaicolor'] : '');
- $list = $this->getChepaicolorList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsEtcTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_etc']) ? $data['is_etc'] : '');
- $list = $this->getIsEtcList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getPowerTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['power']) ? $data['power'] : '');
- $list = $this->getPowerList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getZhucetimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['zhucetime']) ? $data['zhucetime'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getLeasetypeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['leasetype']) ? $data['leasetype'] : '');
- $list = $this->getLeasetypeList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- protected function setZhucetimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- }
|