Doctor.php 3.4 KB

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