DemandOther.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. use think\model\concern\SoftDelete;
  5. class DemandOther 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. 'type' => 'int',
  15. 'title' => 'string',
  16. 'video' => 'string',
  17. 'cateid' => 'int',
  18. 'province' => 'string',
  19. 'city' => 'string',
  20. 'district' => 'string',
  21. 'agegroup' => 'string',
  22. 'tags' => 'string',
  23. 'enddate' => 'int',
  24. 'requirement' => 'string',
  25. 'comdetails' => 'string',
  26. 'picall' => 'string',
  27. 'wtype' => 'tinyint',
  28. 'bwagall' => 'string',
  29. 'zwagall' => 'string',
  30. 'ftype' => 'tinyint',
  31. 'fwagall' => 'string',
  32. 'telephone' => 'string',
  33. 'remark' => 'string',
  34. 'status' => 'tinyint',
  35. 'isfree' => 'tinyint',
  36. 'priority' => 'int',
  37. 'updatetime' => 'int',
  38. 'createtime' => 'int',
  39. 'volume' => 'int',
  40. 'telearr' => 'string',
  41. 'deletetime' => 'int',
  42. 'company_name' => 'string',
  43. 'company_contact' => 'string',
  44. 'company_mobile' => 'string',
  45. ];
  46. // 设置字段自动转换类型
  47. protected $type = [
  48. 'tags' => 'json',
  49. 'telearr' => 'json',
  50. 'picall' => 'json',
  51. 'enddate' => 'timestamp:Y-m-d',
  52. 'updatetime' => 'timestamp:Y-m-d H:i:s',
  53. 'createtime' => 'timestamp:Y-m-d H:i:s',
  54. ];
  55. // 设置JSON数据返回数组
  56. protected $jsonAssoc = true;
  57. public function gettypeTextAttr($value, $data)
  58. {
  59. $wtype = [1 => '代招', 2 => '劳务派遣'];
  60. return $wtype[$data['wtype']];
  61. }
  62. public function getWtypeTextAttr($value, $data)
  63. {
  64. $wtype = [1 => '按月', 2 => '按时', 3 => '按件', 4 => '按项目', 5 => '其他'];
  65. return $wtype[$data['wtype']];
  66. }
  67. public function getFtypeTextAttr($value, $data)
  68. {
  69. $ftype = [1 => '一次性', 2 => '小时工', 3 => '管理费', 4 => '其他'];
  70. return $ftype[$data['ftype']];
  71. }
  72. public function getStatusTextAttr($value, $data)
  73. {
  74. $status = [1 => '待交接', 2 => '部分交接', 3 => '已完成', 4 => '异常'];
  75. return $status[$data['status']];
  76. }
  77. public function getIsfreeTextAttr($value, $data)
  78. {
  79. $isfree = [1 => '否', 2 => '是'];
  80. return $isfree[$data['isfree']];
  81. }
  82. // 关联DemandCate
  83. public function demandCate()
  84. {
  85. return $this->hasOne(DemandCate::class, "id", "cateid");
  86. }
  87. // 关联Worker
  88. public function worker()
  89. {
  90. return $this->hasOne(Worker::class, "id", "workerid");
  91. }
  92. }