Perfect.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. namespace app\admin\model\service\skill;
  3. use think\Model;
  4. class Perfect extends Model
  5. {
  6. // 表名
  7. protected $name = 'service_apply_skill';
  8. // 自动写入时间戳字段
  9. protected $autoWriteTimestamp = 'integer';
  10. // 定义时间戳字段名
  11. protected $createTime = 'createtime';
  12. protected $updateTime = 'updatetime';
  13. protected $deleteTime = false;
  14. // 追加属性
  15. protected $append = [
  16. 'applytype_text',
  17. 'sex_text',
  18. 'edu_text',
  19. 'exper_text',
  20. 'state_text'
  21. ];
  22. public function getApplytypeList()
  23. {
  24. return ['0' => __('Applytype 0'), '1' => __('Applytype 1')];
  25. }
  26. public function getSexList()
  27. {
  28. return ['1' => __('Sex 1'), '0' => __('Sex 0')];
  29. }
  30. public function getEduList()
  31. {
  32. return ['0' => __('Edu 0'), '1' => __('Edu 1'), '2' => __('Edu 2'), '3' => __('Edu 3'), '4' => __('Edu 4'), '5' => __('Edu 5'), '6' => __('Edu 6')];
  33. }
  34. public function getExperList()
  35. {
  36. return ['0' => __('Exper 0'), '1' => __('Exper 1'), '2' => __('Exper 2'), '3' => __('Exper 3')];
  37. }
  38. public function getStateList()
  39. {
  40. return ['0' => __('State 0'), '1' => __('State 1'), '-1' => __('State -1')];
  41. }
  42. public function getApplytypeTextAttr($value, $data)
  43. {
  44. $value = $value ? $value : (isset($data['applytype']) ? $data['applytype'] : '');
  45. $list = $this->getApplytypeList();
  46. return isset($list[$value]) ? $list[$value] : '';
  47. }
  48. public function getSexTextAttr($value, $data)
  49. {
  50. $value = $value ? $value : (isset($data['sex']) ? $data['sex'] : '');
  51. $list = $this->getSexList();
  52. return isset($list[$value]) ? $list[$value] : '';
  53. }
  54. public function getEduTextAttr($value, $data)
  55. {
  56. $value = $value ? $value : (isset($data['edu']) ? $data['edu'] : '');
  57. $list = $this->getEduList();
  58. return isset($list[$value]) ? $list[$value] : '';
  59. }
  60. public function getExperTextAttr($value, $data)
  61. {
  62. $value = $value ? $value : (isset($data['exper']) ? $data['exper'] : '');
  63. $list = $this->getExperList();
  64. return isset($list[$value]) ? $list[$value] : '';
  65. }
  66. public function getStateTextAttr($value, $data)
  67. {
  68. $value = $value ? $value : (isset($data['state']) ? $data['state'] : '');
  69. $list = $this->getStateList();
  70. return isset($list[$value]) ? $list[$value] : '';
  71. }
  72. public function cate()
  73. {
  74. return $this->hasOne('Skillcate','id','skill_cate_id')->field('id,name');
  75. }
  76. public function category()
  77. {
  78. return $this->hasOne('app\admin\model\service\Category','id','category_id')->field('id,name');
  79. }
  80. }