Comjobs.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. use think\model\concern\SoftDelete;
  5. class Comjobs extends Model
  6. {
  7. use SoftDelete;
  8. protected $deleteTime = 'deletetime';
  9. protected $defaultSoftDelete = 0;
  10. // 设置字段信息
  11. protected $schema = [
  12. 'id' => 'int',
  13. 'workerid' => 'int',
  14. 'title' => 'string',
  15. 'video' => 'string',
  16. 'cateid' => 'int',
  17. 'province' => 'string',
  18. 'city' => 'string',
  19. 'district' => 'string',
  20. 'agegroup' => 'string',
  21. 'tags' => 'string',
  22. 'enddate' => 'int',
  23. 'requirement' => 'string',
  24. 'comdetails' => 'string',
  25. 'picall' => 'string',
  26. 'companydetails' => 'string',
  27. 'retmoney' => 'int',
  28. 'wtype' => 'tinyint',
  29. 'bwagall' => 'string',
  30. 'zwagall' => 'string',
  31. 'fwagall' => 'string',
  32. 'telephone' => 'string',
  33. 'remark' => 'string',
  34. 'status' => 'tinyint',
  35. 'priority' => 'int',
  36. 'updatetime' => 'int',
  37. 'createtime' => 'int',
  38. 'volume' => 'int',
  39. 'recruitment_cate' => 'int',
  40. 'latitude' => 'float',
  41. 'longitude' => 'float',
  42. 'address' => 'string',
  43. 'community' => 'string',
  44. 'recruit_num' => 'int',
  45. ];
  46. // 设置字段自动转换类型
  47. protected $type = [
  48. 'tags' => 'json',
  49. 'picall' => 'json',
  50. 'enddate' => 'timestamp:Y-m-d',
  51. 'updatetime' => 'timestamp:Y-m-d H:i:s',
  52. 'createtime' => 'timestamp:Y-m-d H:i:s',
  53. ];
  54. // 设置JSON数据返回数组
  55. protected $jsonAssoc = true;
  56. public function getWtypeTextAttr($value, $data)
  57. {
  58. $wtype = [1 => '按月', 2 => '按时', 3 => '按件', 4 => '按项目', 5 => '面议'];
  59. return $wtype[$data['wtype']];
  60. }
  61. public function getRecruitmentCateTextAttr($value, $data)
  62. {
  63. $recruitment_cate = [1 => '普通招聘', 2 => '无忧聘'];
  64. return $recruitment_cate[$data['recruitment_cate']];
  65. }
  66. public function getStatusTextAttr($value, $data)
  67. {
  68. $status = [1 => '待修改', 2 => '待审核', 3 => '已上架', 4 => '已停招', 5 => '已下架'];
  69. return $status[$data['status']];
  70. }
  71. // 关联ComjobsCate
  72. public function comjobsCate()
  73. {
  74. return $this->hasOne(ComjobsCate::class, "id", "cateid");
  75. }
  76. // 关联Worker
  77. public function worker()
  78. {
  79. return $this->hasOne(Worker::class, "id", "workerid")->removeOption('soft_delete');
  80. }
  81. // 关联ComjobsLog
  82. public function comjobsLog()
  83. {
  84. return $this->hasMany(ComjobsLog::class, "comjobsid", "id");
  85. }
  86. public function ageCode()
  87. {
  88. return $this->hasOne(RensheCode::class, 'name','agegroup');
  89. }
  90. }