12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Userdecoratelianmeng extends Model
- {
-
-
- // 表名
- protected $name = 'user_decorate_lianmeng';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'is_using_text',
- 'status_text',
- 'audittime_text'
- ];
-
-
- public function getIsUsingList()
- {
- return ['1' => __('Is_using 1'), '0' => __('Is_using 0')];
- }
- public function getStatusList()
- {
- return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
- }
- public function getIsUsingTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_using']) ? $data['is_using'] : '');
- $list = $this->getIsUsingList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
- $list = $this->getStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getAudittimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['audittime']) ? $data['audittime'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- protected function setAudittimeAttr($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 decoratelianmeng()
- {
- return $this->belongsTo('Decoratelianmeng', 'decorate_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|