User.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\SoftDeletes;
  4. use Illuminate\Foundation\Auth\User as Authuser;
  5. use Illuminate\Notifications\Notifiable;
  6. use Tymon\JWTAuth\Contracts\JWTSubject;
  7. use Illuminate\Foundation\Auth\User as Authenticatable;
  8. use Illuminate\Auth\MustVerifyEmail as MustVerifyEmailTrait;
  9. use Illuminate\Contracts\Auth\MustVerifyEmail as MustVerifyEmailContract;
  10. use Illuminate\Support\Facades\Auth;
  11. class User extends Authenticatable implements MustVerifyEmailContract, JWTSubject
  12. {
  13. use SoftDeletes;
  14. protected $connection = 'mysql';
  15. /**
  16. * The attributes that are mass assignable.
  17. *
  18. * @var array
  19. */
  20. // use SoftDeletes;
  21. protected $fillable = [
  22. 'nickname','avatar','openid','unionid','tag','status','sex','mobile','auth_code','mobile_code'
  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. }