Worker.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. 'is_public' => 'int',
  36. 'income' => 'decimal',
  37. 'income_total' => 'decimal',
  38. 'idcardzpic' => 'string',
  39. 'idcardfpic' => 'string',
  40. ];
  41. // 设置字段自动转换类型
  42. protected $type = [
  43. 'createtime' => 'timestamp:Y-m-d H:i:s',
  44. ];
  45. public function getWtypeTextAttr($value, $data)
  46. {
  47. $wtype = [1 => '个人雇主', 2 => '企业雇主'];
  48. return $wtype[$data['wtype']];
  49. }
  50. public function getStatusTextAttr($value, $data)
  51. {
  52. $status = [1 => '待审核', 2 => '未通过', 3 => '被禁用', 4 => '升级审核', 5 => '正常中'];
  53. return $status[$data['status']];
  54. }
  55. // 关联User
  56. public function muser()
  57. {
  58. return $this->hasOne(User::class, "id", "userid");
  59. }
  60. // 关联Agent
  61. public function agent()
  62. {
  63. return $this->hasMany(Agent::class, "workerid", "id");
  64. }
  65. // 关联Comjobs
  66. public function comjobs()
  67. {
  68. return $this->hasMany(Comjobs::class, "workerid", "id");
  69. }
  70. // 关联Demand
  71. public function demand()
  72. {
  73. return $this->hasMany(Demand::class, "workerid", "id");
  74. }
  75. }