Worker.php 2.1 KB

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