Worker.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. use think\model\concern\SoftDelete;
  5. class Worker extends Model
  6. {
  7. use SoftDelete;
  8. protected $deleteTime = 'deletetime';
  9. protected $defaultSoftDelete = 0;
  10. // 设置字段信息
  11. protected $schema = [
  12. 'id' => 'int',
  13. 'userid' => 'int',
  14. 'wtype' => 'tinyint',
  15. 'title' => 'string',
  16. 'ftitle' => 'string',
  17. 'tilpic' => 'string',
  18. 'realname' => 'string',
  19. 'mobile' => 'string',
  20. 'weixin' => 'string',
  21. 'latitude' => 'float',
  22. 'longitude' => 'float',
  23. 'province' => 'string',
  24. 'city' => 'string',
  25. 'district' => 'string',
  26. 'address' => 'string',
  27. 'picone' => 'string',
  28. 'pictwo' => 'string',
  29. 'picthr' => 'string',
  30. 'details' => 'string',
  31. 'priority' => 'int',
  32. 'remark' => 'string',
  33. 'status' => 'tinyint',
  34. 'createtime' => 'int'
  35. ];
  36. // 设置字段自动转换类型
  37. protected $type = [
  38. 'createtime' => 'timestamp:Y-m-d H:i:s'
  39. ];
  40. public function getWtypeTextAttr($value,$data)
  41. {
  42. $wtype = [1=>'普通公司',2=>'派遣公司'];
  43. return $wtype[$data['wtype']];
  44. }
  45. public function getStatusTextAttr($value,$data)
  46. {
  47. $status = [1=>'待审核',2=>'未通过',3=>'被禁用',4=>'升级审核',5=>'正常中'];
  48. return $status[$data['status']];
  49. }
  50. // 关联User
  51. public function muser()
  52. {
  53. return $this->hasOne(User::class, "id", "userid");
  54. }
  55. // 关联Agent
  56. public function agent()
  57. {
  58. return $this->hasMany(Agent::class, "workerid", "id");
  59. }
  60. // 关联Comjobs
  61. public function comjobs()
  62. {
  63. return $this->hasMany(Comjobs::class, "workerid", "id");
  64. }
  65. // 关联Demand
  66. public function demand()
  67. {
  68. return $this->hasMany(Demand::class, "workerid", "id");
  69. }
  70. }