HelpExt.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\admin\model\help;
  3. use think\Model;
  4. class HelpExt extends Model
  5. {
  6. // 表名
  7. protected $name = 'help_ext';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = false;
  10. // 定义时间戳字段名
  11. protected $createTime = false;
  12. protected $updateTime = false;
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'sex_text',
  17. 'politics_text',
  18. 'marriage_text',
  19. 'medical_insurance_text'
  20. ];
  21. public function getSexList()
  22. {
  23. return ['0' => __('Sex 0'), '1' => __('Sex 1')];
  24. }
  25. public function getPoliticsList()
  26. {
  27. return ['0' => __('Politics 0'), '1' => __('Politics 1'), '2' => __('Politics 2')];
  28. }
  29. public function getMarriageList()
  30. {
  31. return ['0' => __('Marriage 0'), '1' => __('Marriage 1')];
  32. }
  33. public function getMedicalInsuranceList()
  34. {
  35. return ['0' => __('Medical_insurance 0'), '1' => __('Medical_insurance 1')];
  36. }
  37. public function getSexTextAttr($value, $data)
  38. {
  39. $value = $value ? $value : (isset($data['sex']) ? $data['sex'] : '');
  40. $list = $this->getSexList();
  41. return isset($list[$value]) ? $list[$value] : '';
  42. }
  43. public function getPoliticsTextAttr($value, $data)
  44. {
  45. $value = $value ? $value : (isset($data['politics']) ? $data['politics'] : '');
  46. $list = $this->getPoliticsList();
  47. return isset($list[$value]) ? $list[$value] : '';
  48. }
  49. public function getMarriageTextAttr($value, $data)
  50. {
  51. $value = $value ? $value : (isset($data['marriage']) ? $data['marriage'] : '');
  52. $list = $this->getMarriageList();
  53. return isset($list[$value]) ? $list[$value] : '';
  54. }
  55. public function getMedicalInsuranceTextAttr($value, $data)
  56. {
  57. $value = $value ? $value : (isset($data['medical_insurance']) ? $data['medical_insurance'] : '');
  58. $list = $this->getMedicalInsuranceList();
  59. return isset($list[$value]) ? $list[$value] : '';
  60. }
  61. }