User.php 3.2 KB

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