123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Usermember extends Model
- {
-
-
- // 表名
- protected $table = 'user_member';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
- protected $deleteTime = false;
- // 追加属性
- protected $append = [
- 'gender_text',
- 'marital_status_text',
- 'allergies_status_text',
- 'familymedical_status_text',
- 'chronicdisease_status_text'
- ];
-
-
- public function getGenderList()
- {
- return ['1' => __('Gender 1'), '0' => __('Gender 0')];
- }
- public function getMaritalStatusList()
- {
- return ['1' => __('Marital_status 1'), '0' => __('Marital_status 0')];
- }
- public function getAllergiesStatusList()
- {
- return ['1' => __('Allergies_status 1'), '0' => __('Allergies_status 0')];
- }
- public function getFamilymedicalStatusList()
- {
- return ['1' => __('Familymedical_status 1'), '0' => __('Familymedical_status 0')];
- }
- public function getChronicdiseaseStatusList()
- {
- return ['1' => __('Chronicdisease_status 1'), '0' => __('Chronicdisease_status 0')];
- }
- public function getGenderTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['gender']) ? $data['gender'] : '');
- $list = $this->getGenderList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getMaritalStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['marital_status']) ? $data['marital_status'] : '');
- $list = $this->getMaritalStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getAllergiesStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['allergies_status']) ? $data['allergies_status'] : '');
- $list = $this->getAllergiesStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getFamilymedicalStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['familymedical_status']) ? $data['familymedical_status'] : '');
- $list = $this->getFamilymedicalStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function getChronicdiseaseStatusTextAttr($value, $data)
- {
- $value = $value ? $value : (isset($data['chronicdisease_status']) ? $data['chronicdisease_status'] : '');
- $list = $this->getChronicdiseaseStatusList();
- return isset($list[$value]) ? $list[$value] : '';
- }
- public function user()
- {
- return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
- }
- }
|