Authenticatable.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace Illuminate\Auth;
  3. trait Authenticatable
  4. {
  5. /**
  6. * The column name of the "remember me" token.
  7. *
  8. * @var string
  9. */
  10. protected $rememberTokenName = 'remember_token';
  11. /**
  12. * Get the name of the unique identifier for the user.
  13. *
  14. * @return string
  15. */
  16. public function getAuthIdentifierName()
  17. {
  18. return $this->getKeyName();
  19. }
  20. /**
  21. * Get the unique identifier for the user.
  22. *
  23. * @return mixed
  24. */
  25. public function getAuthIdentifier()
  26. {
  27. return $this->{$this->getAuthIdentifierName()};
  28. }
  29. /**
  30. * Get the password for the user.
  31. *
  32. * @return string
  33. */
  34. public function getAuthPassword()
  35. {
  36. return $this->password;
  37. }
  38. /**
  39. * Get the token value for the "remember me" session.
  40. *
  41. * @return string|null
  42. */
  43. public function getRememberToken()
  44. {
  45. if (! empty($this->getRememberTokenName())) {
  46. return (string) $this->{$this->getRememberTokenName()};
  47. }
  48. }
  49. /**
  50. * Set the token value for the "remember me" session.
  51. *
  52. * @param string $value
  53. * @return void
  54. */
  55. public function setRememberToken($value)
  56. {
  57. if (! empty($this->getRememberTokenName())) {
  58. $this->{$this->getRememberTokenName()} = $value;
  59. }
  60. }
  61. /**
  62. * Get the column name for the "remember me" token.
  63. *
  64. * @return string
  65. */
  66. public function getRememberTokenName()
  67. {
  68. return $this->rememberTokenName;
  69. }
  70. }