Skill.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. namespace app\admin\model\service\skill;
  3. use think\Model;
  4. use traits\model\SoftDelete;
  5. class Skill extends Model
  6. {
  7. use SoftDelete;
  8. // 表名
  9. protected $name = 'service_skill';
  10. // 自动写入时间戳字段
  11. protected $autoWriteTimestamp = 'integer';
  12. // 定义时间戳字段名
  13. protected $createTime = 'createtime';
  14. protected $updateTime = 'updatetime';
  15. protected $deleteTime = 'deletetime';
  16. // 追加属性
  17. protected $append = [
  18. 'sex_text',
  19. 'edu_text',
  20. 'exper_text',
  21. 'is_rest_text',
  22. 'is_train_text',
  23. 'state_text'
  24. ];
  25. protected static function init()
  26. {
  27. self::afterInsert(function ($row) {
  28. $pk = $row->getPk();
  29. $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
  30. });
  31. }
  32. public function getSexList()
  33. {
  34. return ['1' => __('Sex 1'), '0' => __('Sex 0')];
  35. }
  36. public function getEduList()
  37. {
  38. return ['0' => __('Edu 0'), '1' => __('Edu 1'), '2' => __('Edu 2'), '3' => __('Edu 3'), '4' => __('Edu 4'), '5' => __('Edu 5'), '6' => __('Edu 6')];
  39. }
  40. public function getExperList()
  41. {
  42. return ['0' => __('Exper 0'), '1' => __('Exper 1'), '2' => __('Exper 2'), '3' => __('Exper 3')];
  43. }
  44. public function getIsRestList()
  45. {
  46. return ['0' => __('Is_rest 0'), '1' => __('Is_rest 1')];
  47. }
  48. public function getIsTrainList()
  49. {
  50. return ['0' => __('Is_train 0'), '1' => __('Is_train 1')];
  51. }
  52. public function getStateList()
  53. {
  54. return ['0' => __('State 0'), '1' => __('State 1')];
  55. }
  56. public function getSexTextAttr($value, $data)
  57. {
  58. $value = $value ? $value : (isset($data['sex']) ? $data['sex'] : '');
  59. $list = $this->getSexList();
  60. return isset($list[$value]) ? $list[$value] : '';
  61. }
  62. public function getEduTextAttr($value, $data)
  63. {
  64. $value = $value ? $value : (isset($data['edu']) ? $data['edu'] : '');
  65. $list = $this->getEduList();
  66. return isset($list[$value]) ? $list[$value] : '';
  67. }
  68. public function getExperTextAttr($value, $data)
  69. {
  70. $value = $value ? $value : (isset($data['exper']) ? $data['exper'] : '');
  71. $list = $this->getExperList();
  72. return isset($list[$value]) ? $list[$value] : '';
  73. }
  74. public function getIsRestTextAttr($value, $data)
  75. {
  76. $value = $value ? $value : (isset($data['is_rest']) ? $data['is_rest'] : '');
  77. $list = $this->getIsRestList();
  78. return isset($list[$value]) ? $list[$value] : '';
  79. }
  80. public function getIsTrainTextAttr($value, $data)
  81. {
  82. $value = $value ? $value : (isset($data['is_train']) ? $data['is_train'] : '');
  83. $list = $this->getIsTrainList();
  84. return isset($list[$value]) ? $list[$value] : '';
  85. }
  86. public function getStateTextAttr($value, $data)
  87. {
  88. $value = $value ? $value : (isset($data['state']) ? $data['state'] : '');
  89. $list = $this->getStateList();
  90. return isset($list[$value]) ? $list[$value] : '';
  91. }
  92. }