User.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. /**
  14. * The attributes that are mass assignable.
  15. *
  16. * @var array
  17. */
  18. // use SoftDeletes;
  19. protected $fillable = [
  20. 'wechatname','nickname','realname','avatar','openid','unionid','cre_num','level','status','cert_status','agent_id','recom_id','recom_code','sex','register_time','mobile','auth_code','remark_name','headimgurl','password','freeze_status','login_at','freeze_time','h5_num','mini_num'
  21. ];
  22. /**
  23. * The attributes that should be hidden for arrays.
  24. *
  25. * @var array
  26. */
  27. protected $hidden = [
  28. 'password'
  29. ];
  30. /**
  31. * Get the identifier that will be stored in the subject claim of the JWT.
  32. *
  33. * @return mixed
  34. */
  35. public function getJWTIdentifier()
  36. {
  37. return $this->getKey();
  38. }
  39. /**
  40. * Return a key value array, containing any custom claims to be added to the JWT.
  41. *
  42. * @return array
  43. */
  44. public function getJWTCustomClaims()
  45. {
  46. return [];
  47. }
  48. /*
  49. * 邀请人关联
  50. * */
  51. public function recom_user()
  52. {
  53. return $this->belongsTo(User::class,'recom_id');
  54. }
  55. /*
  56. * 用户信息
  57. * */
  58. public function user_info()
  59. {
  60. return $this->belongsTo(User::class,'user_id');
  61. }
  62. /*
  63. *上级关联
  64. *
  65. * */
  66. public function agent_user()
  67. {
  68. return $this->belongsTo(User::class,'agent_id');
  69. }
  70. /*
  71. * 认证表信息
  72. * */
  73. public function cert_info(){
  74. return $this->belongsTo(UserCert::class,'id','user_id');
  75. }
  76. public function get_money(){
  77. return $this->hasMany(UserPay::class,'user_id','id');
  78. }
  79. public function get_moneys(){
  80. return $this->hasMany(UserPay::class,'user_id','id');
  81. }
  82. public function get_moneyss(){
  83. return $this->hasMany(UserPay::class,'user_id','id');
  84. }
  85. public function get_order(){
  86. return $this->hasMany(Ordertest::class,'user_id','id');
  87. }
  88. public function get_store(){
  89. return $this->hasOne(Store::class,'user_id','id');
  90. }
  91. }