Demand.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. use think\model\concern\SoftDelete;
  5. class Demand 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. 'wtype' => 'tinyint',
  27. 'bwagall' => 'string',
  28. 'zwagall' => 'string',
  29. 'ftype' => 'tinyint',
  30. 'fwagall' => 'string',
  31. 'telephone' => 'string',
  32. 'remark' => 'string',
  33. 'status' => 'tinyint',
  34. 'isfree' => 'tinyint',
  35. 'priority' => 'int',
  36. 'updatetime' => 'int',
  37. 'createtime' => 'int',
  38. 'volume' => 'int',
  39. 'telearr' => 'string'
  40. ];
  41. // 设置字段自动转换类型
  42. protected $type = [
  43. 'tags' => 'json',
  44. 'telearr' => 'json',
  45. 'picall' => 'json',
  46. 'enddate' => 'timestamp:Y-m-d',
  47. 'updatetime' => 'timestamp:Y-m-d H:i:s',
  48. 'createtime' => 'timestamp:Y-m-d H:i:s'
  49. ];
  50. // 设置JSON数据返回数组
  51. protected $jsonAssoc = true;
  52. public function getWtypeTextAttr($value,$data)
  53. {
  54. $wtype = [1=>'月薪',2=>'日薪',3=>'时薪',4=>'面议'];
  55. return $wtype[$data['wtype']];
  56. }
  57. public function getFtypeTextAttr($value,$data)
  58. {
  59. $ftype = [1=>'一次性',2=>'小时工',3=>'管理费',4=>'其他'];
  60. return $ftype[$data['ftype']];
  61. }
  62. public function getStatusTextAttr($value,$data)
  63. {
  64. $status = [1=>'待修改',2=>'待审核',3=>'已上架',4=>'已停招',5=>'已下架'];
  65. return $status[$data['status']];
  66. }
  67. public function getIsfreeTextAttr($value,$data)
  68. {
  69. $isfree = [1=>'否',2=>'是'];
  70. return $isfree[$data['isfree']];
  71. }
  72. // 关联DemandCate
  73. public function demandCate()
  74. {
  75. return $this->hasOne(DemandCate::class, "id", "cateid");
  76. }
  77. // 关联Worker
  78. public function worker()
  79. {
  80. return $this->hasOne(Worker::class, "id", "workerid");
  81. }
  82. // 关联DemandLog
  83. public function demandLog()
  84. {
  85. return $this->hasMany(DemandLog::class, "demandid", "id");
  86. }
  87. }