User.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. use think\model\concern\SoftDelete;
  5. class User extends Model
  6. {
  7. use SoftDelete;
  8. protected $deleteTime = 'deletetime';
  9. protected $defaultSoftDelete = 0;
  10. // 设置字段信息
  11. protected $schema = [
  12. 'id' => 'int',
  13. 'groupsid' => 'int',
  14. 'brokerid' => 'int',
  15. 'nickname' => 'string',
  16. 'avatar' => 'string',
  17. 'realname' => 'string',
  18. 'mobile' => 'string',
  19. 'integral' => 'int',
  20. 'inttotal' => 'int',
  21. 'status' => 'tinyint',
  22. 'isvip' => 'tinyint',
  23. 'authstatus' => 'int',
  24. 'authremark' => 'string',
  25. 'idcardzpic' => 'string',
  26. 'idcardfpic' => 'string',
  27. 'idcard' => 'string',
  28. 'gender' => 'tinyint',
  29. 'birthday' => 'string',
  30. 'address' => 'string',
  31. 'education' => 'string',
  32. 'createtime' => 'int',
  33. 'jobintention' => 'string',
  34. 'workexperience' => 'string',
  35. 'eduexperience' => 'string',
  36. 'followstatus' => 'tinyint',
  37. 'wxampcode' => 'string',
  38. 'bankcard' => 'string',
  39. 'emp_time' => 'string',
  40. 'com_cate' => 'string',
  41. 'is_public' => 'int',
  42. 'volume' => 'int',
  43. 'deletetime' => 'int',
  44. 'third_id' => 'int',
  45. ];
  46. // 设置字段自动转换类型
  47. protected $type = [
  48. 'bankcard' => 'json',
  49. 'createtime' => 'timestamp:Y-m-d H:i:s',
  50. 'emp_time' => 'json',
  51. 'com_cate' => 'json',
  52. ];
  53. protected $jsonAssoc = true;
  54. public function getStatusTextAttr($value, $data)
  55. {
  56. $status = [1 => '待审核', 2 => '已通过', 3 => '未通过'];
  57. return $status[$data['status']];
  58. }
  59. public function getIsvipTextAttr($value, $data)
  60. {
  61. $isvip = [1 => '否', 2 => '是'];
  62. return $isvip[$data['isvip']];
  63. }
  64. public function getAuthstatusTextAttr($value, $data)
  65. {
  66. $authstatus = [1 => '待认证', 2 => '待审核', 3 => '已认证'];
  67. return $authstatus[$data['authstatus']];
  68. }
  69. public function getFollowstatusTextAttr($value, $data)
  70. {
  71. $followstatus = [1 => '未跟进', 2 => '未面试', 3 => '面试通过', 4 => '面试未通过', 5 => '用户放弃', 6 => '已入职', 7 => '已离职'];
  72. return $followstatus[$data['followstatus']];
  73. }
  74. public function getEducationTextAttr($value, $data)
  75. {
  76. $education = ['' => '', 1 => '初中', 2 => '高中', 3 => '中技', 4 => '中专', 5 => '大专', 6 => '本科', 7 => '硕士', 8 => '博士'];
  77. return $education[$data['education']];
  78. }
  79. public function getWorkerTextAttr($value, $data)
  80. {
  81. $experience = ['' => '', 1 => '无经验', 2 => '一年以下', 3 => '1-3年', 4 => '3-5年', 5 => '5-10年', 6 => '10年以上'];
  82. return $experience[$data['workexperience']];
  83. }
  84. public function getJobintentionTextAttr($value, $data)
  85. {
  86. $title = '';
  87. if ($data['jobintention']) {
  88. $title = UserWill::where('id', $data['jobintention'])->value('title');
  89. }
  90. return $title;
  91. }
  92. // 关联UserGroups
  93. public function userGroups()
  94. {
  95. return $this->hasOne(UserGroups::class, "id", "groupsid");
  96. }
  97. // 关联Broker
  98. public function broker()
  99. {
  100. return $this->hasOne(Broker::class, "id", "brokerid");
  101. }
  102. // 关联UserPart
  103. public function userPart()
  104. {
  105. return $this->hasMany(UserPart::class, "puserid", "id");
  106. }
  107. // 关联UserAuths
  108. public function userAuths()
  109. {
  110. return $this->hasMany(UserAuths::class, "userid", "id");
  111. }
  112. // 关联UserFollow
  113. public function userFollow()
  114. {
  115. return $this->hasMany(UserFollow::class, "userid", "id")->order('id', 'desc');
  116. }
  117. }