Merge pull request #276 from 1day2die/Out_of_credits_adminview
Show Client running out of Credits in Admin overview
This commit is contained in:
commit
8e9895a40a
4 changed files with 39 additions and 5 deletions
|
@ -251,7 +251,7 @@ class UserController extends Controller
|
|||
return '<i class="fas fa-coins mr-2"></i> ' . $user->credits();
|
||||
})
|
||||
->addColumn('usage', function (User $user) {
|
||||
return '<i class="fas fa-coins mr-2"></i> ' . $user->creditUsage();
|
||||
return '<i class="fas fa-coins mr-2"></i> ' . $user->creditUsage(). ' ('.$user->outOfCredits().')';
|
||||
})
|
||||
->addColumn('verified', function (User $user) {
|
||||
return $user->getVerifiedStatus();
|
||||
|
|
|
@ -80,9 +80,9 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
'last_seen' => 'datetime',
|
||||
'credits' => 'float',
|
||||
'server_limit' => 'float',
|
||||
'last_seen' => 'datetime',
|
||||
'credits' => 'float',
|
||||
'server_limit' => 'float',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -242,6 +242,26 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||
return number_format($usage, 2, '.', '');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description Returns the Users "out of Credits" time
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function outOfCredits()
|
||||
{
|
||||
$usage = $this->creditUsage();
|
||||
$credits = $this->credits;
|
||||
$timeLeft = number_format(($credits * 30) / $usage);
|
||||
$unit = "days";
|
||||
|
||||
if ($timeLeft < 1) {
|
||||
$timeLeft = number_format(($credits * 30) / $usage * 24, 2);
|
||||
$unit = "hours";
|
||||
}
|
||||
return $timeLeft . " " . $unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|string|string[]
|
||||
*/
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
<th>Role</th>
|
||||
<th>Email</th>
|
||||
<th>{{CREDITS_DISPLAY_NAME}}</th>
|
||||
<th>Usage</th>
|
||||
<th>Usage (Out of Credits in..)</th>
|
||||
<th>Servers</th>
|
||||
<th>Verified</th>
|
||||
<th>Last seen</th>
|
||||
|
|
|
@ -184,6 +184,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-lg-6">
|
||||
<div class="row">
|
||||
<div class="col-lg-4">
|
||||
|
@ -197,6 +198,19 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
<div class="row">
|
||||
<div class="col-lg-4">
|
||||
<label>Out of Credits in</label>
|
||||
</div>
|
||||
<div class="col-lg-8">
|
||||
<span style="max-width: 250px;" class="d-inline-block text-truncate">
|
||||
<i class="fas fa-clock mr-2"></i>{{$user->OutOfCredits()}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
<div class="row">
|
||||
<div class="col-lg-4">
|
||||
|
|
Loading…
Reference in a new issue