UserItem.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. # app/MicroApi/Services/ResponseHandler.php
  3. namespace App\MicroApi\Items;
  4. use Illuminate\Contracts\Auth\Authenticatable;
  5. use Illuminate\Auth\Passwords\CanResetPassword;
  6. use Illuminate\Notifications\RoutesNotifications;
  7. use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
  8. class UserItem implements Authenticatable, CanResetPasswordContract
  9. {
  10. use RoutesNotifications, CanResetPassword;
  11. public $remember_token;
  12. public $id;
  13. public $name;
  14. public $email;
  15. public $password;
  16. public $status;
  17. protected $hidden = ['password'];
  18. /**
  19. * 将 JSON 序列化对象数据填充到 UserItem
  20. */
  21. public function fillAttributes($data)
  22. {
  23. if (is_object($data)) {
  24. $data = get_object_vars($data);
  25. }
  26. foreach ($data as $key => $value) {
  27. if (in_array($key, $this->hidden)) {
  28. continue;
  29. }
  30. switch ($key) {
  31. case 'id':
  32. $this->id = $value;
  33. break;
  34. case 'name':
  35. $this->name = $value;
  36. break;
  37. case 'email':
  38. $this->email = $value;
  39. break;
  40. case 'status':
  41. $this->status = $value;
  42. break;
  43. default:
  44. break;
  45. }
  46. }
  47. return $this;
  48. }
  49. /**
  50. * Get the name of the unique identifier for the user.
  51. *
  52. * @return string
  53. */
  54. public function getAuthIdentifierName()
  55. {
  56. return 'id';
  57. }
  58. /**
  59. * Get the unique identifier for the user.
  60. *
  61. * @return mixed
  62. */
  63. public function getAuthIdentifier()
  64. {
  65. return $this->id;
  66. }
  67. /**
  68. * Get the password for the user.
  69. *
  70. * @return string
  71. */
  72. public function getAuthPassword()
  73. {
  74. return $this->password;
  75. }
  76. /**
  77. * Get the token value for the "remember me" session.
  78. *
  79. * @return string
  80. */
  81. public function getRememberToken()
  82. {
  83. return $this->remember_token;
  84. }
  85. /**
  86. * Set the token value for the "remember me" session.
  87. *
  88. * @param string $value
  89. * @return void
  90. */
  91. public function setRememberToken($value)
  92. {
  93. $this->remember_token = $value;
  94. }
  95. /**
  96. * Get the column name for the "remember me" token.
  97. *
  98. * @return string
  99. */
  100. public function getRememberTokenName()
  101. {
  102. return 'remember_token';
  103. }
  104. }