@@ -1,15 +1,15 @@ discard block |
||
1 | -<?php |
|
1 | + <?php |
|
2 | 2 | |
3 | -namespace App\Models; |
|
3 | + namespace App\Models; |
|
4 | 4 | |
5 | -use Illuminate\Auth\Authenticatable; |
|
6 | -use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; |
|
7 | -use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; |
|
8 | -use Illuminate\Database\Eloquent\Model; |
|
9 | -use Illuminate\Support\Facades\Config; |
|
10 | -use Laravel\Lumen\Auth\Authorizable; |
|
11 | -use Sofa\Eloquence\Eloquence; |
|
12 | -use Sofa\Eloquence\Mappable; |
|
5 | + use Illuminate\Auth\Authenticatable; |
|
6 | + use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; |
|
7 | + use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; |
|
8 | + use Illuminate\Database\Eloquent\Model; |
|
9 | + use Illuminate\Support\Facades\Config; |
|
10 | + use Laravel\Lumen\Auth\Authorizable; |
|
11 | + use Sofa\Eloquence\Eloquence; |
|
12 | + use Sofa\Eloquence\Mappable; |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * Class User. |
@@ -20,77 +20,77 @@ discard block |
||
20 | 20 | * @property string name |
21 | 21 | * @property string motto |
22 | 22 | */ |
23 | -class User extends Model implements AuthenticatableContract, AuthorizableContract |
|
24 | -{ |
|
25 | - use Authenticatable, Authorizable, Eloquence, Mappable; |
|
23 | + class User extends Model implements AuthenticatableContract, AuthorizableContract |
|
24 | + { |
|
25 | + use Authenticatable, Authorizable, Eloquence, Mappable; |
|
26 | 26 | |
27 | - /** |
|
27 | + /** |
|
28 | 28 | * Disable Timestamps. |
29 | 29 | * |
30 | 30 | * @var bool |
31 | 31 | */ |
32 | - public $timestamps = false; |
|
32 | + public $timestamps = false; |
|
33 | 33 | |
34 | - /** |
|
34 | + /** |
|
35 | 35 | * User Traits. |
36 | 36 | * |
37 | 37 | * @var array |
38 | 38 | */ |
39 | - public $traits = ['USER']; |
|
39 | + public $traits = ['USER']; |
|
40 | 40 | |
41 | - /** |
|
41 | + /** |
|
42 | 42 | * The table associated with the model. |
43 | 43 | * |
44 | 44 | * @var string |
45 | 45 | */ |
46 | - protected $table = 'users'; |
|
46 | + protected $table = 'users'; |
|
47 | 47 | |
48 | - /** |
|
48 | + /** |
|
49 | 49 | * Primary Key of the Table. |
50 | 50 | * |
51 | 51 | * @var string |
52 | 52 | */ |
53 | - protected $primaryKey = 'id'; |
|
53 | + protected $primaryKey = 'id'; |
|
54 | 54 | |
55 | - /** |
|
55 | + /** |
|
56 | 56 | * The attributes that will be mapped. |
57 | 57 | * |
58 | 58 | * @var array |
59 | 59 | */ |
60 | - protected $maps = ['uniqueId' => 'id', 'name' => 'username', 'figureString' => 'look', 'lastWebAccess' => 'last_login', 'creationTime' => 'account_created', 'email' => 'mail', 'identityId' => 'id', 'accountId' => 'id']; |
|
60 | + protected $maps = ['uniqueId' => 'id', 'name' => 'username', 'figureString' => 'look', 'lastWebAccess' => 'last_login', 'creationTime' => 'account_created', 'email' => 'mail', 'identityId' => 'id', 'accountId' => 'id']; |
|
61 | 61 | |
62 | - /** |
|
62 | + /** |
|
63 | 63 | * The Appender(s) of the Model. |
64 | 64 | * |
65 | 65 | * @var array |
66 | 66 | */ |
67 | - protected $appends = ['habboClubMember', 'buildersClubMember', 'sessionLoginId', 'loginLogId', 'identityVerified', 'identityType', 'trusted', 'country', 'traits', |
|
68 | - 'uniqueId', 'name', 'figureString', 'lastWebAccess', 'creationTime', 'email', 'identityId', 'emailVerified', 'accountId', 'memberSince', 'isBanned', 'banDetails', 'isStaff', ]; |
|
67 | + protected $appends = ['habboClubMember', 'buildersClubMember', 'sessionLoginId', 'loginLogId', 'identityVerified', 'identityType', 'trusted', 'country', 'traits', |
|
68 | + 'uniqueId', 'name', 'figureString', 'lastWebAccess', 'creationTime', 'email', 'identityId', 'emailVerified', 'accountId', 'memberSince', 'isBanned', 'banDetails', 'isStaff', ]; |
|
69 | 69 | |
70 | - /** |
|
70 | + /** |
|
71 | 71 | * The attributes that are mass assignable. |
72 | 72 | * |
73 | 73 | * @var array |
74 | 74 | */ |
75 | - protected $fillable = ['mail', 'id', 'username', 'auth_ticket', 'last_login', 'ip_current', 'ip_register', 'mail_verified', 'account_day_of_birth', |
|
76 | - 'real_name', 'look', 'gender', 'credits', 'pixels', 'home_room', ]; |
|
75 | + protected $fillable = ['mail', 'id', 'username', 'auth_ticket', 'last_login', 'ip_current', 'ip_register', 'mail_verified', 'account_day_of_birth', |
|
76 | + 'real_name', 'look', 'gender', 'credits', 'pixels', 'home_room', ]; |
|
77 | 77 | |
78 | - /** |
|
78 | + /** |
|
79 | 79 | * The attributes excluded from the model's JSON form. |
80 | 80 | * |
81 | 81 | * @var array |
82 | 82 | */ |
83 | - protected $hidden = ['id', 'username', 'mail', 'account_created', 'password', 'mail_verified', 'real_name', 'account_day_of_birth', |
|
84 | - 'last_online', 'last_login', 'ip_register', 'auth_ticket', 'home_room', 'points', 'look', 'ip_current', 'online', 'pixels', 'credits', 'gender', 'points', 'rank', ]; |
|
83 | + protected $hidden = ['id', 'username', 'mail', 'account_created', 'password', 'mail_verified', 'real_name', 'account_day_of_birth', |
|
84 | + 'last_online', 'last_login', 'ip_register', 'auth_ticket', 'home_room', 'points', 'look', 'ip_current', 'online', 'pixels', 'credits', 'gender', 'points', 'rank', ]; |
|
85 | 85 | |
86 | - /** |
|
86 | + /** |
|
87 | 87 | * The attributes that should be casted to native types. |
88 | 88 | * |
89 | 89 | * @var array |
90 | 90 | */ |
91 | - protected $casts = ['traits' => 'string']; |
|
91 | + protected $casts = ['traits' => 'string']; |
|
92 | 92 | |
93 | - /** |
|
93 | + /** |
|
94 | 94 | * Store an User on the Database. |
95 | 95 | * |
96 | 96 | * @param string $username |
@@ -100,164 +100,164 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return User |
102 | 102 | */ |
103 | - public function store(string $username, string $email, string $address = '', bool $newUser = true): User |
|
104 | - { |
|
105 | - $this->attributes['username'] = $username; |
|
106 | - $this->attributes['mail'] = $email; |
|
103 | + public function store(string $username, string $email, string $address = '', bool $newUser = true): User |
|
104 | + { |
|
105 | + $this->attributes['username'] = $username; |
|
106 | + $this->attributes['mail'] = $email; |
|
107 | 107 | |
108 | - $this->attributes['motto'] = Config::get('chocolatey.motto'); |
|
109 | - $this->attributes['look'] = Config::get('chocolatey.figure'); |
|
110 | - $this->attributes['auth_ticket'] = ''; |
|
108 | + $this->attributes['motto'] = Config::get('chocolatey.motto'); |
|
109 | + $this->attributes['look'] = Config::get('chocolatey.figure'); |
|
110 | + $this->attributes['auth_ticket'] = ''; |
|
111 | 111 | |
112 | - $this->attributes['password'] = hash(Config::get('chocolatey.security.hash'), openssl_random_pseudo_bytes(50)); |
|
113 | - $this->attributes['account_created'] = time(); |
|
112 | + $this->attributes['password'] = hash(Config::get('chocolatey.security.hash'), openssl_random_pseudo_bytes(50)); |
|
113 | + $this->attributes['account_created'] = time(); |
|
114 | 114 | |
115 | - $this->attributes['ip_current'] = $address; |
|
115 | + $this->attributes['ip_current'] = $address; |
|
116 | 116 | |
117 | - $this->traits = $newUser ? ['NEW_USER', 'USER'] : ['USER']; |
|
117 | + $this->traits = $newUser ? ['NEW_USER', 'USER'] : ['USER']; |
|
118 | 118 | |
119 | - $this->save(); |
|
120 | - $this->createData(); |
|
119 | + $this->save(); |
|
120 | + $this->createData(); |
|
121 | 121 | |
122 | - return $this; |
|
123 | - } |
|
122 | + return $this; |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
125 | + /** |
|
126 | 126 | * Store an User Alias Set on Database. |
127 | 127 | */ |
128 | - public function createData() |
|
129 | - { |
|
130 | - (new UserPreferences())->store($this->attributes['id']); |
|
131 | - } |
|
128 | + public function createData() |
|
129 | + { |
|
130 | + (new UserPreferences())->store($this->attributes['id']); |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
133 | + /** |
|
134 | 134 | * Get Is User is Banned. |
135 | 135 | * |
136 | 136 | * @return bool |
137 | 137 | */ |
138 | - public function getIsBannedAttribute(): bool |
|
139 | - { |
|
140 | - $ban = Ban::where('user_id', $this->attributes['id'])->first(); |
|
138 | + public function getIsBannedAttribute(): bool |
|
139 | + { |
|
140 | + $ban = Ban::where('user_id', $this->attributes['id'])->first(); |
|
141 | 141 | |
142 | - if($ban == null) { |
|
143 | - return false; |
|
144 | - } |
|
142 | + if($ban == null) { |
|
143 | + return false; |
|
144 | + } |
|
145 | 145 | |
146 | - return $ban->ban_expire >= time(); |
|
147 | - } |
|
146 | + return $ban->ban_expire >= time(); |
|
147 | + } |
|
148 | 148 | |
149 | - /** |
|
149 | + /** |
|
150 | 150 | * Check if Is Staff. |
151 | 151 | * |
152 | 152 | * @return bool |
153 | 153 | */ |
154 | - public function getIsStaffAttribute(): bool |
|
155 | - { |
|
156 | - return array_key_exists('rank', $this->attributes) ? $this->attributes['rank'] >= 5 : false; |
|
157 | - } |
|
154 | + public function getIsStaffAttribute(): bool |
|
155 | + { |
|
156 | + return array_key_exists('rank', $this->attributes) ? $this->attributes['rank'] >= 5 : false; |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
159 | + /** |
|
160 | 160 | * Get Ban Details. |
161 | 161 | * |
162 | 162 | * @return Ban |
163 | 163 | */ |
164 | - public function getBanDetailsAttribute() |
|
165 | - { |
|
166 | - return Ban::where('user_id', $this->attributes['id'])->first(); |
|
167 | - } |
|
164 | + public function getBanDetailsAttribute() |
|
165 | + { |
|
166 | + return Ban::where('user_id', $this->attributes['id'])->first(); |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
169 | + /** |
|
170 | 170 | * Get Current User Country. |
171 | 171 | * |
172 | 172 | * @TODO: Implement this in a proper way |
173 | 173 | * |
174 | 174 | * @return string |
175 | 175 | */ |
176 | - public function getCountryAttribute(): string |
|
177 | - { |
|
178 | - return 'com'; |
|
179 | - } |
|
176 | + public function getCountryAttribute(): string |
|
177 | + { |
|
178 | + return 'com'; |
|
179 | + } |
|
180 | 180 | |
181 | - /** |
|
181 | + /** |
|
182 | 182 | * Set the Trait Attribute. |
183 | 183 | * |
184 | 184 | * @param array $accountType |
185 | 185 | */ |
186 | - public function setTraitsAttribute(array $accountType) |
|
187 | - { |
|
188 | - $this->traits = $accountType; |
|
189 | - } |
|
186 | + public function setTraitsAttribute(array $accountType) |
|
187 | + { |
|
188 | + $this->traits = $accountType; |
|
189 | + } |
|
190 | 190 | |
191 | - /** |
|
191 | + /** |
|
192 | 192 | * What is this field? |
193 | 193 | * |
194 | 194 | * @return array |
195 | 195 | */ |
196 | - public function getTraitsAttribute(): array |
|
197 | - { |
|
198 | - if (array_key_exists('rank', $this->attributes) && $this->attributes['rank'] >= 6) { |
|
199 | - return ['STAFF']; |
|
200 | - } |
|
196 | + public function getTraitsAttribute(): array |
|
197 | + { |
|
198 | + if (array_key_exists('rank', $this->attributes) && $this->attributes['rank'] >= 6) { |
|
199 | + return ['STAFF']; |
|
200 | + } |
|
201 | 201 | |
202 | - return $this->traits; |
|
203 | - } |
|
202 | + return $this->traits; |
|
203 | + } |
|
204 | 204 | |
205 | - /** |
|
205 | + /** |
|
206 | 206 | * We don't care about this? |
207 | 207 | * |
208 | 208 | * @return bool |
209 | 209 | */ |
210 | - public function getTrustedAttribute(): bool |
|
211 | - { |
|
212 | - if (UserSecurity::find($this->attributes['id']) == null) { |
|
213 | - return true; |
|
214 | - } |
|
210 | + public function getTrustedAttribute(): bool |
|
211 | + { |
|
212 | + if (UserSecurity::find($this->attributes['id']) == null) { |
|
213 | + return true; |
|
214 | + } |
|
215 | 215 | |
216 | - return in_array($this->attributes['ip_current'], |
|
217 | - UserSecurity::find($this->attributes['id'])->trustedDevices); |
|
218 | - } |
|
216 | + return in_array($this->attributes['ip_current'], |
|
217 | + UserSecurity::find($this->attributes['id'])->trustedDevices); |
|
218 | + } |
|
219 | 219 | |
220 | - /** |
|
220 | + /** |
|
221 | 221 | * What is this field? |
222 | 222 | * |
223 | 223 | * @return string |
224 | 224 | */ |
225 | - public function getIdentityTypeAttribute(): string |
|
226 | - { |
|
227 | - return 'HABBO'; |
|
228 | - } |
|
225 | + public function getIdentityTypeAttribute(): string |
|
226 | + { |
|
227 | + return 'HABBO'; |
|
228 | + } |
|
229 | 229 | |
230 | - /** |
|
230 | + /** |
|
231 | 231 | * We don't care about this, every user is trusted. |
232 | 232 | * |
233 | 233 | * @return bool |
234 | 234 | */ |
235 | - public function getIdentityVerifiedAttribute(): bool |
|
236 | - { |
|
237 | - return true; |
|
238 | - } |
|
235 | + public function getIdentityVerifiedAttribute(): bool |
|
236 | + { |
|
237 | + return true; |
|
238 | + } |
|
239 | 239 | |
240 | - /** |
|
240 | + /** |
|
241 | 241 | * We don't care about this. |
242 | 242 | * |
243 | 243 | * @return int |
244 | 244 | */ |
245 | - public function getLoginLogIdAttribute(): int |
|
246 | - { |
|
247 | - return 1; |
|
248 | - } |
|
245 | + public function getLoginLogIdAttribute(): int |
|
246 | + { |
|
247 | + return 1; |
|
248 | + } |
|
249 | 249 | |
250 | - /** |
|
250 | + /** |
|
251 | 251 | * We don't care about this. |
252 | 252 | * |
253 | 253 | * @return int |
254 | 254 | */ |
255 | - public function getSessionLoginIdAttribute(): int |
|
256 | - { |
|
257 | - return 1; |
|
258 | - } |
|
255 | + public function getSessionLoginIdAttribute(): int |
|
256 | + { |
|
257 | + return 1; |
|
258 | + } |
|
259 | 259 | |
260 | - /** |
|
260 | + /** |
|
261 | 261 | * Get the HabboClub Attribute |
262 | 262 | * In a Retro Habbo everyone is HC, yeah? |
263 | 263 | * |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return bool |
267 | 267 | */ |
268 | - public function getHabboClubMemberAttribute(): bool |
|
269 | - { |
|
270 | - return Config::get('chocolatey.ads.enabled') == false; |
|
271 | - } |
|
268 | + public function getHabboClubMemberAttribute(): bool |
|
269 | + { |
|
270 | + return Config::get('chocolatey.ads.enabled') == false; |
|
271 | + } |
|
272 | 272 | |
273 | - /** |
|
273 | + /** |
|
274 | 274 | * Get the Builders Club Attribute |
275 | 275 | * In a Retro Habbo everyone is BC, yeah? |
276 | 276 | * |
@@ -278,74 +278,74 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return bool |
280 | 280 | */ |
281 | - public function getBuildersClubMemberAttribute(): bool |
|
282 | - { |
|
283 | - return Config::get('chocolatey.ads.enabled') == false; |
|
284 | - } |
|
281 | + public function getBuildersClubMemberAttribute(): bool |
|
282 | + { |
|
283 | + return Config::get('chocolatey.ads.enabled') == false; |
|
284 | + } |
|
285 | 285 | |
286 | - /** |
|
286 | + /** |
|
287 | 287 | * Get GTimestamp in Habbo UserCurrency. |
288 | 288 | * |
289 | 289 | * @return string |
290 | 290 | */ |
291 | - public function getAccountCreatedAttribute(): string |
|
292 | - { |
|
293 | - $accountCreated = $this->attributes['account_created'] ?? time(); |
|
291 | + public function getAccountCreatedAttribute(): string |
|
292 | + { |
|
293 | + $accountCreated = $this->attributes['account_created'] ?? time(); |
|
294 | 294 | |
295 | - return date('Y-m-d', $accountCreated).'T'.date('H:i:s.ZZZZ+ZZZZ', $accountCreated); |
|
296 | - } |
|
295 | + return date('Y-m-d', $accountCreated).'T'.date('H:i:s.ZZZZ+ZZZZ', $accountCreated); |
|
296 | + } |
|
297 | 297 | |
298 | - /** |
|
298 | + /** |
|
299 | 299 | * Get GTimestamp in Habbo UserCurrency. |
300 | 300 | * |
301 | 301 | * @return string |
302 | 302 | */ |
303 | - public function getMemberSinceAttribute(): string |
|
304 | - { |
|
305 | - $accountCreated = $this->attributes['account_created'] ?? time(); |
|
303 | + public function getMemberSinceAttribute(): string |
|
304 | + { |
|
305 | + $accountCreated = $this->attributes['account_created'] ?? time(); |
|
306 | 306 | |
307 | - return date('Y-m-d', $accountCreated).'T'.date('H:i:s.ZZZZ+ZZZZ', $accountCreated); |
|
308 | - } |
|
307 | + return date('Y-m-d', $accountCreated).'T'.date('H:i:s.ZZZZ+ZZZZ', $accountCreated); |
|
308 | + } |
|
309 | 309 | |
310 | - /** |
|
310 | + /** |
|
311 | 311 | * Retrieve User Figure String. |
312 | 312 | * |
313 | 313 | * @return string |
314 | 314 | */ |
315 | - public function getFigureStringAttribute(): string |
|
316 | - { |
|
317 | - return $this->attributes['look'] ?? 'hr-115-42.hd-195-19.ch-3030-82.lg-275-1408.fa-1201.ca-1804-64'; |
|
318 | - } |
|
315 | + public function getFigureStringAttribute(): string |
|
316 | + { |
|
317 | + return $this->attributes['look'] ?? 'hr-115-42.hd-195-19.ch-3030-82.lg-275-1408.fa-1201.ca-1804-64'; |
|
318 | + } |
|
319 | 319 | |
320 | - /** |
|
320 | + /** |
|
321 | 321 | * Get GTimestamp in Habbo UserCurrency. |
322 | 322 | * |
323 | 323 | * @return false|string |
324 | 324 | */ |
325 | - public function getLastLoginAttribute(): string |
|
326 | - { |
|
327 | - $lastLogin = $this->attributes['last_login'] ?? time(); |
|
325 | + public function getLastLoginAttribute(): string |
|
326 | + { |
|
327 | + $lastLogin = $this->attributes['last_login'] ?? time(); |
|
328 | 328 | |
329 | - return date('Y-m-d', $lastLogin).'T'.date('H:i:s.ZZZZ+ZZZZ', $lastLogin); |
|
330 | - } |
|
329 | + return date('Y-m-d', $lastLogin).'T'.date('H:i:s.ZZZZ+ZZZZ', $lastLogin); |
|
330 | + } |
|
331 | 331 | |
332 | - /** |
|
332 | + /** |
|
333 | 333 | * Get E-Mail Verified Attribute. |
334 | 334 | * |
335 | 335 | * @return bool |
336 | 336 | */ |
337 | - public function getEmailVerifiedAttribute(): bool |
|
338 | - { |
|
339 | - return $this->getChocolateyId()->mail_verified ?? false; |
|
340 | - } |
|
337 | + public function getEmailVerifiedAttribute(): bool |
|
338 | + { |
|
339 | + return $this->getChocolateyId()->mail_verified ?? false; |
|
340 | + } |
|
341 | 341 | |
342 | - /** |
|
342 | + /** |
|
343 | 343 | * Get Account Chocolatey Id. |
344 | 344 | * |
345 | 345 | * @return ChocolateyId |
346 | 346 | */ |
347 | - public function getChocolateyId() |
|
348 | - { |
|
349 | - return ChocolateyId::find($this->attributes['mail']); |
|
350 | - } |
|
347 | + public function getChocolateyId() |
|
348 | + { |
|
349 | + return ChocolateyId::find($this->attributes['mail']); |
|
350 | + } |
|
351 | 351 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | { |
140 | 140 | $ban = Ban::where('user_id', $this->attributes['id'])->first(); |
141 | 141 | |
142 | - if($ban == null) { |
|
142 | + if ($ban == null) { |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | { |
293 | 293 | $accountCreated = $this->attributes['account_created'] ?? time(); |
294 | 294 | |
295 | - return date('Y-m-d', $accountCreated).'T'.date('H:i:s.ZZZZ+ZZZZ', $accountCreated); |
|
295 | + return date('Y-m-d', $accountCreated) . 'T' . date('H:i:s.ZZZZ+ZZZZ', $accountCreated); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | { |
305 | 305 | $accountCreated = $this->attributes['account_created'] ?? time(); |
306 | 306 | |
307 | - return date('Y-m-d', $accountCreated).'T'.date('H:i:s.ZZZZ+ZZZZ', $accountCreated); |
|
307 | + return date('Y-m-d', $accountCreated) . 'T' . date('H:i:s.ZZZZ+ZZZZ', $accountCreated); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | { |
327 | 327 | $lastLogin = $this->attributes['last_login'] ?? time(); |
328 | 328 | |
329 | - return date('Y-m-d', $lastLogin).'T'.date('H:i:s.ZZZZ+ZZZZ', $lastLogin); |
|
329 | + return date('Y-m-d', $lastLogin) . 'T' . date('H:i:s.ZZZZ+ZZZZ', $lastLogin); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |