123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class User extends Model
- {
-
-
- // 表名
- protected $table = 'user';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'integer';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'birthday_text',
- 'prevtime_text',
- 'logintime_text',
- 'jointime_text',
- 'status_text',
- 'oldstatus_text',
- 'notice_email_text',
- 'notice_whatsapp_text',
- 'notice_phonecall_text',
- 'is_first_text'
- ];
-
-
- public function getStatusList()
- {
- return ['-1' => __('Status -1'), '0' => __('Status 0'), '1' => __('Status 1')];
- }
- public function getOldstatusList()
- {
- return ['0' => __('Oldstatus 0'), '1' => __('Oldstatus 1')];
- }
- public function getNoticeEmailList()
- {
- return ['1' => __('Notice_email 1'), '0' => __('Notice_email 0')];
- }
- public function getNoticeWhatsappList()
- {
- return ['1' => __('Notice_whatsapp 1'), '0' => __('Notice_whatsapp 0')];
- }
- public function getNoticePhonecallList()
- {
- return ['1' => __('Notice_phonecall 1'), '0' => __('Notice_phonecall 0')];
- }
- public function getIsFirstList()
- {
- return ['0' => __('Is_first 0'), '1' => __('Is_first 1')];
- }
- public function getPrevtimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['prevtime']) ? $data['prevtime'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getBirthdayTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['birthday']) ? $data['birthday'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getLogintimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['logintime']) ? $data['logintime'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
- }
- public function getJointimeTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['jointime']) ? $data['jointime'] : '');
- return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $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 getOldstatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['oldstatus']) ? $data['oldstatus'] : '');
- $list = $this->getOldstatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getNoticeEmailTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['notice_email']) ? $data['notice_email'] : '');
- $list = $this->getNoticeEmailList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getNoticeWhatsappTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['notice_whatsapp']) ? $data['notice_whatsapp'] : '');
- $list = $this->getNoticeWhatsappList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getNoticePhonecallTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['notice_phonecall']) ? $data['notice_phonecall'] : '');
- $list = $this->getNoticePhonecallList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getIsFirstTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['is_first']) ? $data['is_first'] : '');
- $list = $this->getIsFirstList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- protected function setPrevtimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setBirthdayAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setLogintimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- protected function setJointimeAttr($value)
- {
- return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
- }
- public function userwallet()
- {
- return $this->belongsTo('Userwallet', 'id', 'user_id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|