Doctor.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. 'gender_text',
  17. 'idcard_status_text',
  18. 'doctor_status_text',
  19. 'english_status_text',
  20. 'status_text'
  21. ];
  22. public function getGenderList()
  23. {
  24. return ['1' => __('Gender 1'), '0' => __('Gender 0')];
  25. }
  26. public function getIdcardStatusList()
  27. {
  28. return ['-1' => __('Idcard_status -1'), '0' => __('Idcard_status 0'), '1' => __('Idcard_status 1'), '2' => __('Idcard_status 2'), '3' => __('Idcard_status 3')];
  29. }
  30. public function getDoctorStatusList()
  31. {
  32. return ['-1' => __('Doctor_status -1'), '0' => __('Doctor_status 0'), '1' => __('Doctor_status 1'), '2' => __('Doctor_status 2'), '3' => __('Doctor_status 3')];
  33. }
  34. public function getEnglishStatusList()
  35. {
  36. return ['1' => __('English_status 1'), '0' => __('English_status 0')];
  37. }
  38. public function getStatusList()
  39. {
  40. return ['1' => __('Status 1'), '0' => __('Status 0'), '-1' => __('Status -1')];
  41. }
  42. public function getGenderTextAttr($value, $data)
  43. {
  44. $value = $value ? $value : (isset($data['gender']) ? $data['gender'] : '');
  45. $list = $this->getGenderList();
  46. return isset($list[$value]) ? $list[$value] : '';
  47. }
  48. public function getIdcardStatusTextAttr($value, $data)
  49. {
  50. $value = $value ? $value : (isset($data['idcard_status']) ? $data['idcard_status'] : '');
  51. $list = $this->getIdcardStatusList();
  52. return isset($list[$value]) ? $list[$value] : '';
  53. }
  54. public function getDoctorStatusTextAttr($value, $data)
  55. {
  56. $value = $value ? $value : (isset($data['doctor_status']) ? $data['doctor_status'] : '');
  57. $list = $this->getDoctorStatusList();
  58. return isset($list[$value]) ? $list[$value] : '';
  59. }
  60. public function getEnglishStatusTextAttr($value, $data)
  61. {
  62. $value = $value ? $value : (isset($data['english_status']) ? $data['english_status'] : '');
  63. $list = $this->getEnglishStatusList();
  64. return isset($list[$value]) ? $list[$value] : '';
  65. }
  66. public function getStatusTextAttr($value, $data)
  67. {
  68. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  69. $list = $this->getStatusList();
  70. return isset($list[$value]) ? $list[$value] : '';
  71. }
  72. public function keshi()
  73. {
  74. return $this->belongsTo('Keshi', 'keshi_id', 'id', [], 'LEFT')->setEagerlyType(0);
  75. }
  76. public function doctorlevel()
  77. {
  78. return $this->belongsTo('doctorlevel', 'level_id', 'id', [], 'LEFT')->setEagerlyType(0);
  79. }
  80. }