githubtrue/backend/vendor/illuminate/auth/GenericUser.php @ f24e2d9d
1 |
<?php
|
---|---|
2 |
|
3 |
namespace Illuminate\Auth; |
4 |
|
5 |
use Illuminate\Contracts\Auth\Authenticatable as UserContract; |
6 |
|
7 |
class GenericUser implements UserContract |
8 |
{
|
9 |
/**
|
10 |
* All of the user's attributes.
|
11 |
*
|
12 |
* @var array
|
13 |
*/
|
14 |
protected $attributes; |
15 |
|
16 |
/**
|
17 |
* Create a new generic User object.
|
18 |
*
|
19 |
* @param array $attributes
|
20 |
* @return void
|
21 |
*/
|
22 |
public function __construct(array $attributes) |
23 |
{
|
24 |
$this->attributes = $attributes; |
25 |
}
|
26 |
|
27 |
/**
|
28 |
* Get the name of the unique identifier for the user.
|
29 |
*
|
30 |
* @return string
|
31 |
*/
|
32 |
public function getAuthIdentifierName() |
33 |
{
|
34 |
return 'id'; |
35 |
}
|
36 |
|
37 |
/**
|
38 |
* Get the unique identifier for the user.
|
39 |
*
|
40 |
* @return mixed
|
41 |
*/
|
42 |
public function getAuthIdentifier() |
43 |
{
|
44 |
$name = $this->getAuthIdentifierName(); |
45 |
|
46 |
return $this->attributes[$name]; |
47 |
}
|
48 |
|
49 |
/**
|
50 |
* Get the password for the user.
|
51 |
*
|
52 |
* @return string
|
53 |
*/
|
54 |
public function getAuthPassword() |
55 |
{
|
56 |
return $this->attributes['password']; |
57 |
}
|
58 |
|
59 |
/**
|
60 |
* Get the "remember me" token value.
|
61 |
*
|
62 |
* @return string
|
63 |
*/
|
64 |
public function getRememberToken() |
65 |
{
|
66 |
return $this->attributes[$this->getRememberTokenName()]; |
67 |
}
|
68 |
|
69 |
/**
|
70 |
* Set the "remember me" token value.
|
71 |
*
|
72 |
* @param string $value
|
73 |
* @return void
|
74 |
*/
|
75 |
public function setRememberToken($value) |
76 |
{
|
77 |
$this->attributes[$this->getRememberTokenName()] = $value; |
78 |
}
|
79 |
|
80 |
/**
|
81 |
* Get the column name for the "remember me" token.
|
82 |
*
|
83 |
* @return string
|
84 |
*/
|
85 |
public function getRememberTokenName() |
86 |
{
|
87 |
return 'remember_token'; |
88 |
}
|
89 |
|
90 |
/**
|
91 |
* Dynamically access the user's attributes.
|
92 |
*
|
93 |
* @param string $key
|
94 |
* @return mixed
|
95 |
*/
|
96 |
public function __get($key) |
97 |
{
|
98 |
return $this->attributes[$key]; |
99 |
}
|
100 |
|
101 |
/**
|
102 |
* Dynamically set an attribute on the user.
|
103 |
*
|
104 |
* @param string $key
|
105 |
* @param mixed $value
|
106 |
* @return void
|
107 |
*/
|
108 |
public function __set($key, $value) |
109 |
{
|
110 |
$this->attributes[$key] = $value; |
111 |
}
|
112 |
|
113 |
/**
|
114 |
* Dynamically check if a value is set on the user.
|
115 |
*
|
116 |
* @param string $key
|
117 |
* @return bool
|
118 |
*/
|
119 |
public function __isset($key) |
120 |
{
|
121 |
return isset($this->attributes[$key]); |
122 |
}
|
123 |
|
124 |
/**
|
125 |
* Dynamically unset a value on the user.
|
126 |
*
|
127 |
* @param string $key
|
128 |
* @return void
|
129 |
*/
|
130 |
public function __unset($key) |
131 |
{
|
132 |
unset($this->attributes[$key]); |
133 |
}
|
134 |
}
|