Doctor.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. use think\Model;
  5. /**
  6. * 会员模型
  7. */
  8. class Doctor extends Model
  9. {
  10. // 表名
  11. protected $name = 'doctor';
  12. // 开启自动写入时间戳字段
  13. protected $autoWriteTimestamp = false;
  14. // 定义时间戳字段名
  15. protected $createTime = false;
  16. protected $updateTime = false;
  17. // 追加属性
  18. protected $append = [
  19. 'gender_text',
  20. 'idcard_status_text',
  21. 'doctor_status_text',
  22. 'english_status_text',
  23. 'status_text'
  24. ];
  25. public function getGenderList()
  26. {
  27. return ['1' => __('Gender 1'), '0' => __('Gender 0')];
  28. }
  29. public function getIdcardStatusList()
  30. {
  31. return ['-1' => __('Idcard_status -1'), '0' => __('Idcard_status 0'), '1' => __('Idcard_status 1'), '2' => __('Idcard_status 2'), '3' => __('Idcard_status 3')];
  32. }
  33. public function getDoctorStatusList()
  34. {
  35. return ['-1' => __('Doctor_status -1'), '0' => __('Doctor_status 0'), '1' => __('Doctor_status 1'), '2' => __('Doctor_status 2'), '3' => __('Doctor_status 3')];
  36. }
  37. public function getEnglishStatusList()
  38. {
  39. return ['1' => __('English_status 1'), '0' => __('English_status 0')];
  40. }
  41. public function getStatusList()
  42. {
  43. return ['1' => __('Status 1'), '0' => __('Status 0'), '-1' => __('Status -1')];
  44. }
  45. public function getGenderTextAttr($value, $data)
  46. {
  47. $value = $value ? $value : (isset($data['gender']) ? $data['gender'] : '');
  48. $list = $this->getGenderList();
  49. return isset($list[$value]) ? $list[$value] : '';
  50. }
  51. public function getIdcardStatusTextAttr($value, $data)
  52. {
  53. $value = $value ? $value : (isset($data['idcard_status']) ? $data['idcard_status'] : '');
  54. $list = $this->getIdcardStatusList();
  55. return isset($list[$value]) ? $list[$value] : '';
  56. }
  57. public function getDoctorStatusTextAttr($value, $data)
  58. {
  59. $value = $value ? $value : (isset($data['doctor_status']) ? $data['doctor_status'] : '');
  60. $list = $this->getDoctorStatusList();
  61. return isset($list[$value]) ? $list[$value] : '';
  62. }
  63. public function getEnglishStatusTextAttr($value, $data)
  64. {
  65. $value = $value ? $value : (isset($data['english_status']) ? $data['english_status'] : '');
  66. $list = $this->getEnglishStatusList();
  67. return isset($list[$value]) ? $list[$value] : '';
  68. }
  69. public function getStatusTextAttr($value, $data)
  70. {
  71. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  72. $list = $this->getStatusList();
  73. return isset($list[$value]) ? $list[$value] : '';
  74. }
  75. public function keshi()
  76. {
  77. return $this->belongsTo('Keshi', 'keshi_id', 'id', [], 'LEFT')->setEagerlyType(0);
  78. }
  79. public function doctorlevel()
  80. {
  81. return $this->belongsTo('doctorlevel', 'level_id', 'id', [], 'LEFT')->setEagerlyType(0);
  82. }
  83. }