User.php 3.3 KB

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