UserItem.php 2.3 KB

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