123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <?php
-
- namespace Illuminate\Auth;
-
- use Illuminate\Contracts\Auth\Authenticatable as UserContract;
-
- class GenericUser implements UserContract
- {
- /**
- * All of the user's attributes.
- *
- * @var array
- */
- protected $attributes;
-
- /**
- * Create a new generic User object.
- *
- * @param array $attributes
- * @return void
- */
- public function __construct(array $attributes)
- {
- $this->attributes = $attributes;
- }
-
- /**
- * Get the name of the unique identifier for the user.
- *
- * @return string
- */
- public function getAuthIdentifierName()
- {
- return 'id';
- }
-
- /**
- * Get the unique identifier for the user.
- *
- * @return mixed
- */
- public function getAuthIdentifier()
- {
- $name = $this->getAuthIdentifierName();
-
- return $this->attributes[$name];
- }
-
- /**
- * Get the password for the user.
- *
- * @return string
- */
- public function getAuthPassword()
- {
- return $this->attributes['password'];
- }
-
- /**
- * Get the "remember me" token value.
- *
- * @return string
- */
- public function getRememberToken()
- {
- return $this->attributes[$this->getRememberTokenName()];
- }
-
- /**
- * Set the "remember me" token value.
- *
- * @param string $value
- * @return void
- */
- public function setRememberToken($value)
- {
- $this->attributes[$this->getRememberTokenName()] = $value;
- }
-
- /**
- * Get the column name for the "remember me" token.
- *
- * @return string
- */
- public function getRememberTokenName()
- {
- return 'remember_token';
- }
-
- /**
- * Dynamically access the user's attributes.
- *
- * @param string $key
- * @return mixed
- */
- public function __get($key)
- {
- return $this->attributes[$key];
- }
-
- /**
- * Dynamically set an attribute on the user.
- *
- * @param string $key
- * @param mixed $value
- * @return void
- */
- public function __set($key, $value)
- {
- $this->attributes[$key] = $value;
- }
-
- /**
- * Dynamically check if a value is set on the user.
- *
- * @param string $key
- * @return bool
- */
- public function __isset($key)
- {
- return isset($this->attributes[$key]);
- }
-
- /**
- * Dynamically unset a value on the user.
- *
- * @param string $key
- * @return void
- */
- public function __unset($key)
- {
- unset($this->attributes[$key]);
- }
- }
|