User.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. ];
  42. // 设置字段自动转换类型
  43. protected $type = [
  44. 'bankcard' => 'json',
  45. 'createtime' => 'timestamp:Y-m-d H:i:s',
  46. 'emp_time' => 'json',
  47. 'com_cate' => 'json',
  48. ];
  49. protected $jsonAssoc = true;
  50. public function getStatusTextAttr($value,$data)
  51. {
  52. $status = [1=>'待审核', 2=>'已通过', 3=>'未通过'];
  53. return $status[$data['status']];
  54. }
  55. public function getIsvipTextAttr($value,$data)
  56. {
  57. $isvip = [1=>'否', 2=>'是'];
  58. return $isvip[$data['isvip']];
  59. }
  60. public function getAuthstatusTextAttr($value,$data)
  61. {
  62. $authstatus = [1=>'待认证', 2=>'待审核', 3=>'已认证'];
  63. return $authstatus[$data['authstatus']];
  64. }
  65. public function getFollowstatusTextAttr($value,$data)
  66. {
  67. $followstatus = [1=>'未跟进', 2=>'未面试', 3=>'面试通过', 4=>'面试未通过', 5=>'用户放弃', 6=>'已入职', 7=>'已离职'];
  68. return $followstatus[$data['followstatus']];
  69. }
  70. public function getEducationTextAttr($value,$data)
  71. {
  72. $education = [''=>'',1=>'初中', 2=>'高中', 3=>'中技',4=>'中专', 5=>'大专', 6=>'本科', 7=>'硕士', 8=>'博士'];
  73. return $education[$data['education']];
  74. }
  75. public function getWorkerTextAttr($value,$data)
  76. {
  77. $experience = [''=>'',1=>'无经验', 2=>'一年以下', 3=>'1-3年',4=>'3-5年', 5=>'5-10年', 6=>'10年以上'];
  78. return $experience[$data['workexperience']];
  79. }
  80. public function getJobintentionTextAttr($value,$data)
  81. {
  82. $title = '';
  83. if($data['jobintention']){
  84. $title = UserWill::where('id',$data['jobintention'])->value('title');
  85. }
  86. return $title;
  87. }
  88. // 关联UserGroups
  89. public function userGroups()
  90. {
  91. return $this->hasOne(UserGroups::class, "id", "groupsid");
  92. }
  93. // 关联Broker
  94. public function broker()
  95. {
  96. return $this->hasOne(Broker::class, "id", "brokerid");
  97. }
  98. // 关联UserPart
  99. public function userPart()
  100. {
  101. return $this->hasMany(UserPart::class, "puserid", "id");
  102. }
  103. // 关联UserAuths
  104. public function userAuths()
  105. {
  106. return $this->hasMany(UserAuths::class, "userid", "id");
  107. }
  108. // 关联UserFollow
  109. public function userFollow()
  110. {
  111. return $this->hasMany(UserFollow::class, "userid", "id")->order('id','desc');
  112. }
  113. }