User.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Auth\Authenticatable;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. use Laravel\Lumen\Auth\Authorizable;
  6. use Illuminate\Database\Eloquent\Model;
  7. use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
  8. use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
  9. use Tymon\JWTAuth\Contracts\JWTSubject;
  10. class User extends Model implements AuthenticatableContract, AuthorizableContract, JWTSubject
  11. {
  12. use Authenticatable, Authorizable;
  13. protected $connection = 'mysql';
  14. /**
  15. * The attributes that are mass assignable.
  16. *
  17. * @var array
  18. */
  19. // use SoftDeletes;
  20. protected $fillable = [
  21. 'wechatname','nickname','realname','avatar','openid','unionid','cre_num','level','status','cert_status','agent_id','recom_id','recom_code','sex','service_time','service_end_time','register_time','area_code','mobile','auth_code','remark_name','headimgurl','password','freeze_status','login_at','freeze_time','h5_num','mini_num','is_five_type'
  22. ];
  23. /**
  24. * The attributes that should be hidden for arrays.
  25. *
  26. * @var array
  27. */
  28. protected $hidden = [
  29. 'password'
  30. ];
  31. /**
  32. * Get the identifier that will be stored in the subject claim of the JWT.
  33. *
  34. * @return mixed
  35. */
  36. public function getJWTIdentifier()
  37. {
  38. return $this->getKey();
  39. }
  40. /**
  41. * Return a key value array, containing any custom claims to be added to the JWT.
  42. *
  43. * @return array
  44. */
  45. public function getJWTCustomClaims()
  46. {
  47. return [];
  48. }
  49. /*
  50. * 邀请人关联
  51. * */
  52. public function recom_user()
  53. {
  54. return $this->belongsTo(User::class,'recom_id');
  55. }
  56. /*
  57. * 用户信息
  58. * */
  59. public function user_info()
  60. {
  61. return $this->belongsTo(User::class,'user_id');
  62. }
  63. /*
  64. *上级关联
  65. *
  66. * */
  67. public function agent_user()
  68. {
  69. return $this->belongsTo(User::class,'agent_id');
  70. }
  71. /*
  72. *代理公司关联
  73. *
  74. * */
  75. public function crown_info()
  76. {
  77. return $this->belongsTo(User::class,'crown_id');
  78. }
  79. /*
  80. * 认证表信息
  81. * */
  82. public function cert_info(){
  83. return $this->belongsTo(UserCert::class,'id','user_id');
  84. }
  85. public function cert_user(){
  86. return $this->hasOne(UserCert::class,'user_id','id');
  87. }
  88. public function get_money(){
  89. return $this->hasMany(UserPay::class,'user_id','id');
  90. }
  91. public function get_moneys(){
  92. return $this->hasMany(UserPay::class,'user_id','id');
  93. }
  94. public function get_moneyss(){
  95. return $this->hasMany(UserPay::class,'user_id','id');
  96. }
  97. public function get_order(){
  98. return $this->hasMany(Ordertest::class,'user_id','id');
  99. }
  100. public function get_store(){
  101. return $this->hasOne(Store::class,'user_id','id');
  102. }
  103. }