|
@@ -59,7 +59,8 @@ class User extends Authenticatable implements MustVerifyEmail
|
|
|
'password',
|
|
|
'pterodactyl_id',
|
|
|
'discord_verified_at',
|
|
|
- 'avatar'
|
|
|
+ 'avatar',
|
|
|
+ 'suspended'
|
|
|
];
|
|
|
|
|
|
/**
|
|
@@ -79,7 +80,7 @@ class User extends Authenticatable implements MustVerifyEmail
|
|
|
*/
|
|
|
protected $casts = [
|
|
|
'email_verified_at' => 'datetime',
|
|
|
- 'last_seen' => 'datetime',
|
|
|
+ 'last_seen' => 'datetime',
|
|
|
];
|
|
|
|
|
|
/**
|
|
@@ -94,13 +95,13 @@ class User extends Authenticatable implements MustVerifyEmail
|
|
|
});
|
|
|
|
|
|
static::deleting(function (User $user) {
|
|
|
- $user->servers()->chunk(10 , function ($servers) {
|
|
|
+ $user->servers()->chunk(10, function ($servers) {
|
|
|
foreach ($servers as $server) {
|
|
|
$server->delete();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- $user->payments()->chunk(10 , function ($payments) {
|
|
|
+ $user->payments()->chunk(10, function ($payments) {
|
|
|
foreach ($payments as $payment) {
|
|
|
$payment->delete();
|
|
|
}
|
|
@@ -114,6 +115,38 @@ class User extends Authenticatable implements MustVerifyEmail
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @return HasMany
|
|
|
+ */
|
|
|
+ public function servers()
|
|
|
+ {
|
|
|
+ return $this->hasMany(Server::class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return HasMany
|
|
|
+ */
|
|
|
+ public function payments()
|
|
|
+ {
|
|
|
+ return $this->hasMany(Payment::class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return BelongsToMany
|
|
|
+ */
|
|
|
+ public function vouchers()
|
|
|
+ {
|
|
|
+ return $this->belongsToMany(Voucher::class);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return HasOne
|
|
|
+ */
|
|
|
+ public function discordUser()
|
|
|
+ {
|
|
|
+ return $this->hasOne(DiscordUser::class);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
*/
|
|
@@ -131,65 +164,70 @@ class User extends Authenticatable implements MustVerifyEmail
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @return string
|
|
|
+ * @return bool
|
|
|
*/
|
|
|
- public function getAvatar(){
|
|
|
- return "https://www.gravatar.com/avatar/" . md5(strtolower(trim($this->email)));
|
|
|
+ public function isSuspended()
|
|
|
+ {
|
|
|
+ return $this->suspended;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @return string
|
|
|
+ *
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
- public function creditUsage()
|
|
|
+ public function suspend()
|
|
|
{
|
|
|
- $usage = 0;
|
|
|
-
|
|
|
- foreach ($this->Servers as $server){
|
|
|
- $usage += $server->product->price;
|
|
|
- }
|
|
|
+ $this->update([
|
|
|
+ 'suspended' => true
|
|
|
+ ]);
|
|
|
|
|
|
- return number_format($usage, 2, '.', '');
|
|
|
+ return $this;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @return array|string|string[]
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
- public function getVerifiedStatus(){
|
|
|
- $status = '';
|
|
|
- if ($this->hasVerifiedEmail()) $status .= 'email ';
|
|
|
- if ($this->discordUser()->exists()) $status .= 'discord';
|
|
|
- $status = str_replace(' ' , '/' , $status);
|
|
|
- return $status;
|
|
|
- }
|
|
|
+ public function unSuspend()
|
|
|
+ {
|
|
|
+ $this->update([
|
|
|
+ 'suspended' => false
|
|
|
+ ]);
|
|
|
|
|
|
- /**
|
|
|
- * @return BelongsToMany
|
|
|
- */
|
|
|
- public function vouchers(){
|
|
|
- return $this->belongsToMany(Voucher::class);
|
|
|
+ return $this;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @return HasOne
|
|
|
+ * @return string
|
|
|
*/
|
|
|
- public function discordUser(){
|
|
|
- return $this->hasOne(DiscordUser::class);
|
|
|
+ public function getAvatar()
|
|
|
+ {
|
|
|
+ return "https://www.gravatar.com/avatar/" . md5(strtolower(trim($this->email)));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @return HasMany
|
|
|
+ * @return string
|
|
|
*/
|
|
|
- public function servers()
|
|
|
+ public function creditUsage()
|
|
|
{
|
|
|
- return $this->hasMany(Server::class);
|
|
|
+ $usage = 0;
|
|
|
+
|
|
|
+ foreach ($this->Servers as $server) {
|
|
|
+ $usage += $server->product->price;
|
|
|
+ }
|
|
|
+
|
|
|
+ return number_format($usage, 2, '.', '');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @return HasMany
|
|
|
+ * @return array|string|string[]
|
|
|
*/
|
|
|
- public function payments()
|
|
|
+ public function getVerifiedStatus()
|
|
|
{
|
|
|
- return $this->hasMany(Payment::class);
|
|
|
+ $status = '';
|
|
|
+ if ($this->hasVerifiedEmail()) $status .= 'email ';
|
|
|
+ if ($this->discordUser()->exists()) $status .= 'discord';
|
|
|
+ $status = str_replace(' ', '/', $status);
|
|
|
+ return $status;
|
|
|
}
|
|
|
|
|
|
}
|