Donate.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\admin\model;
  3. use think\Model;
  4. class Donate extends Model
  5. {
  6. // 表名
  7. protected $name = 'donate';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'int';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = false;
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'sex_text',
  17. 'education_text',
  18. 'status_text'
  19. ];
  20. public function getSexList()
  21. {
  22. return ['0' => __('Sex 0'), '1' => __('Sex 1')];
  23. }
  24. public function getEducationList()
  25. {
  26. return ['0' => __('Education 0'), '1' => __('Education 1'), '2' => __('Education 2'), '3' => __('Education 3'), '4' => __('Education 4'), '5' => __('Education 5'), '6' => __('Education 6'), '7' => __('Education 7'), '8' => __('Education 8'), '9' => __('Education 9')];
  27. }
  28. public function getStatusList()
  29. {
  30. return ['-1' => __('Status -1'), '0' => __('Status 0'), '1' => __('Status 1')];
  31. }
  32. public function getSexTextAttr($value, $data)
  33. {
  34. $value = $value ? $value : (isset($data['sex']) ? $data['sex'] : '');
  35. $list = $this->getSexList();
  36. return isset($list[$value]) ? $list[$value] : '';
  37. }
  38. public function getEducationTextAttr($value, $data)
  39. {
  40. $value = $value ? $value : (isset($data['education']) ? $data['education'] : '');
  41. $list = $this->getEducationList();
  42. return isset($list[$value]) ? $list[$value] : '';
  43. }
  44. public function getStatusTextAttr($value, $data)
  45. {
  46. $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
  47. $list = $this->getStatusList();
  48. return isset($list[$value]) ? $list[$value] : '';
  49. }
  50. }