1 | <?php |
||
66 | class User extends ModelAbstract implements AuthenticatableContract, CanResetPasswordContract |
||
67 | { |
||
68 | use Authenticatable, |
||
69 | CanResetPassword, |
||
70 | UserRelations, |
||
71 | UserScopes, |
||
72 | LoggedUser, |
||
73 | Authorizable; |
||
74 | |||
75 | /** |
||
76 | * User name is private. |
||
77 | * |
||
78 | * @var int |
||
79 | */ |
||
80 | const PRIVATE_YES = 1; |
||
81 | |||
82 | /** |
||
83 | * User name is public. |
||
84 | * |
||
85 | * @var int |
||
86 | */ |
||
87 | const PRIVATE_NO = 0; |
||
88 | |||
89 | /** |
||
90 | * User status Deleted. |
||
91 | * |
||
92 | * @var int |
||
93 | */ |
||
94 | const DELETED_USERS = 1; |
||
95 | |||
96 | /** |
||
97 | * User status not deleted. |
||
98 | * |
||
99 | * @var int |
||
100 | */ |
||
101 | const NOT_DELETED_USERS = 0; |
||
102 | |||
103 | /** |
||
104 | * User status active. (Standard). |
||
105 | * |
||
106 | * @var int |
||
107 | */ |
||
108 | const ACTIVE_USER = 1; |
||
109 | |||
110 | /** |
||
111 | * User status blocked. (Too many login attempts). |
||
112 | * |
||
113 | * @var int |
||
114 | */ |
||
115 | const BLOCKED_USER = 2; |
||
116 | |||
117 | /** |
||
118 | * User status inactive. (Cannot login at the moment). |
||
119 | * |
||
120 | * @var int |
||
121 | */ |
||
122 | const INACTIVE_USER = 0; |
||
123 | |||
124 | /** |
||
125 | * The database table used by the model. |
||
126 | * |
||
127 | * @var string |
||
128 | */ |
||
129 | protected $table = 'users'; |
||
130 | |||
131 | /** |
||
132 | * The attributes that are mass assignable. |
||
133 | * |
||
134 | * @var array |
||
135 | */ |
||
136 | protected $fillable = ['deleted', 'email', 'password', 'firstname', 'lastname', 'role_id', 'private', 'language', 'status']; |
||
137 | |||
138 | /** |
||
139 | * @param User|null $user |
||
140 | * |
||
141 | * @return \Tinyissue\Repository\User\Updater |
||
142 | */ |
||
143 | public function updater(User $user = null) |
||
147 | |||
148 | /** |
||
149 | * The attributes excluded from the model's JSON form. |
||
150 | * |
||
151 | * @var array |
||
152 | */ |
||
153 | protected $hidden = ['password', 'remember_token']; |
||
154 | |||
155 | /** |
||
156 | * Checks to see if $this user is current user. |
||
157 | * |
||
158 | * @return bool |
||
159 | */ |
||
160 | public function me() |
||
164 | |||
165 | /** |
||
166 | * Return user full name with property "fullname". |
||
167 | * |
||
168 | * @return string |
||
169 | */ |
||
170 | public function getFullNameAttribute() |
||
178 | |||
179 | /** |
||
180 | * Return user image. |
||
181 | * |
||
182 | * @return string |
||
183 | */ |
||
184 | public function getImageAttribute() |
||
188 | |||
189 | /** |
||
190 | * Returns list of user statuses. |
||
191 | * |
||
192 | * @return array |
||
193 | */ |
||
194 | public static function getStatuses() |
||
202 | |||
203 | /** |
||
204 | * Whether or not the user is active. |
||
205 | * |
||
206 | * @return bool |
||
207 | */ |
||
208 | public function isActive() |
||
212 | |||
213 | /** |
||
214 | * Whether or not the user is inactive. |
||
215 | * |
||
216 | * @return bool |
||
217 | */ |
||
218 | public function isInactive() |
||
222 | |||
223 | /** |
||
224 | * Whether or not the user is blocked. |
||
225 | * |
||
226 | * @return bool |
||
227 | */ |
||
228 | public function isBlocked() |
||
232 | |||
233 | /** |
||
234 | * Whether or not the user is normal user role. |
||
235 | * |
||
236 | * @return bool |
||
237 | */ |
||
238 | public function isUser() |
||
242 | |||
243 | /** |
||
244 | * Whether or not the user is administrator. |
||
245 | * |
||
246 | * @return bool |
||
247 | */ |
||
248 | public function isAdmin() |
||
252 | |||
253 | /** |
||
254 | * Whether or not the user is manager. |
||
255 | * |
||
256 | * @return bool |
||
257 | */ |
||
258 | public function isManager() |
||
262 | |||
263 | /** |
||
264 | * Whether or not the user is developer. |
||
265 | * |
||
266 | * @return bool |
||
267 | */ |
||
268 | public function isDeveloper() |
||
272 | |||
273 | /** |
||
274 | * Whether or not the user is manager or admin. |
||
275 | * |
||
276 | * @return bool |
||
277 | */ |
||
278 | public function isManagerOrMore() |
||
282 | |||
283 | /** |
||
284 | * Whether or not the user is developer or manager or admin. |
||
285 | * |
||
286 | * @return bool |
||
287 | */ |
||
288 | public function isDeveloperOrMore() |
||
292 | |||
293 | /** |
||
294 | * Get user role name. |
||
295 | * |
||
296 | * @return string |
||
297 | */ |
||
298 | public function getRoleName() |
||
302 | } |
||
303 |