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