User.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Auth\Authenticatable;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. use Illuminate\Support\Facades\Crypt;
  6. use Laravel\Lumen\Auth\Authorizable;
  7. use Illuminate\Database\Eloquent\Model;
  8. use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
  9. use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
  10. use Tymon\JWTAuth\Contracts\JWTSubject;
  11. class User extends Model implements AuthenticatableContract, AuthorizableContract, JWTSubject
  12. {
  13. use Authenticatable, Authorizable;
  14. protected $connection = 'mysql';
  15. /**
  16. * The attributes that are mass assignable.
  17. *
  18. * @var array
  19. */
  20. // use SoftDeletes;
  21. protected $fillable = [
  22. 'wechatname','nickname','realname','avatar','openid','unionid','cre_num','level','status','cert_status','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'
  23. ];
  24. /**
  25. * The attributes that should be hidden for arrays.
  26. *
  27. * @var array
  28. */
  29. protected $hidden = [
  30. 'password'
  31. ];
  32. /**
  33. * Get the identifier that will be stored in the subject claim of the JWT.
  34. *
  35. * @return mixed
  36. */
  37. public function getJWTIdentifier()
  38. {
  39. return $this->getKey();
  40. }
  41. /**
  42. * Return a key value array, containing any custom claims to be added to the JWT.
  43. *
  44. * @return array
  45. */
  46. public function getJWTCustomClaims()
  47. {
  48. return [];
  49. }
  50. /*
  51. * 用户信息
  52. * */
  53. public function user_info()
  54. {
  55. return $this->belongsTo(User::class,'user_id');
  56. }
  57. /*
  58. * 认证表信息
  59. * */
  60. public function cert_info(){
  61. return $this->belongsTo(UserCert::class,'id','user_id');
  62. }
  63. public function cert_user(){
  64. return $this->hasOne(UserCert::class,'user_id','id');
  65. }
  66. public function get_order(){
  67. return $this->hasMany(Ordertest::class,'user_id','id');
  68. }
  69. public function get_store(){
  70. return $this->hasOne(Store::class,'user_id','id');
  71. }
  72. }