Comjobs.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. ];
  45. // 设置字段自动转换类型
  46. protected $type = [
  47. 'tags' => 'json',
  48. 'picall' => 'json',
  49. 'enddate' => 'timestamp:Y-m-d',
  50. 'updatetime' => 'timestamp:Y-m-d H:i:s',
  51. 'createtime' => 'timestamp:Y-m-d H:i:s',
  52. ];
  53. // 设置JSON数据返回数组
  54. protected $jsonAssoc = true;
  55. public function getWtypeTextAttr($value, $data)
  56. {
  57. $wtype = [1 => '月薪', 2 => '日薪', 3 => '时薪', 4 => '面议'];
  58. return $wtype[$data['wtype']];
  59. }
  60. public function getRecruitmentCateTextAttr($value, $data)
  61. {
  62. $recruitment_cate = [1 => '普通招聘', 2 => '无忧聘'];
  63. return $recruitment_cate[$data['recruitment_cate']];
  64. }
  65. public function getStatusTextAttr($value, $data)
  66. {
  67. $status = [1 => '待修改', 2 => '待审核', 3 => '已上架', 4 => '已停招', 5 => '已下架'];
  68. return $status[$data['status']];
  69. }
  70. // 关联ComjobsCate
  71. public function comjobsCate()
  72. {
  73. return $this->hasOne(ComjobsCate::class, "id", "cateid");
  74. }
  75. // 关联Worker
  76. public function worker()
  77. {
  78. return $this->hasOne(Worker::class, "id", "workerid")->removeOption('soft_delete');
  79. }
  80. // 关联ComjobsLog
  81. public function comjobsLog()
  82. {
  83. return $this->hasMany(ComjobsLog::class, "comjobsid", "id");
  84. }
  85. }