User.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\api\model;
  3. use think\Model;
  4. class User extends Model
  5. {
  6. // 表名
  7. protected $name = 'user';
  8. public function getGenderList()
  9. {
  10. return ['1' => __('Gender 1'), '0' => __('Gender 0')];
  11. }
  12. public function getIdcardStatusList()
  13. {
  14. return ['-1' => __('Idcard_status -1'),'0' => __('Idcard_status 0'),'1' => __('Idcard_status 1'), '2' => __('Idcard_status 2')];
  15. }
  16. public function getStatusList()
  17. {
  18. return ['1' => __('Status 1'), '0' => __('Status 0')];
  19. }
  20. public function getGenderTextAttr($value, $data)
  21. {
  22. $value = $value ? $value : (isset($data['gender']) ? $data['gender'] : '');
  23. $list = $this->getGenderList();
  24. return isset($list[$value]) ? $list[$value] : '';
  25. }
  26. public function getIdcardStatusTextAttr($value, $data)
  27. {
  28. $value = $value ? $value : (isset($data['idcard_status']) ? $data['idcard_status'] : '');
  29. $list = $this->getIdcardStatusList();
  30. return isset($list[$value]) ? $list[$value] : '';
  31. }
  32. public function getStatusTextAttr($value, $data)
  33. {
  34. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  35. $list = $this->getStatusList();
  36. return isset($list[$value]) ? $list[$value] : '';
  37. }
  38. }