diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 50c4fc5e..7a58dc3b 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -251,7 +251,7 @@ class UserController extends Controller return ' ' . $user->credits(); }) ->addColumn('usage', function (User $user) { - return ' ' . $user->creditUsage(); + return ' ' . $user->creditUsage(). ' ('.$user->outOfCredits().')'; }) ->addColumn('verified', function (User $user) { return $user->getVerifiedStatus(); diff --git a/app/Models/User.php b/app/Models/User.php index 9c1d8568..b82c4a03 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -242,6 +242,20 @@ class User extends Authenticatable implements MustVerifyEmail return number_format($usage, 2, '.', ''); } + 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[] */ diff --git a/resources/views/admin/users/index.blade.php b/resources/views/admin/users/index.blade.php index 885b1c31..2e5704d0 100644 --- a/resources/views/admin/users/index.blade.php +++ b/resources/views/admin/users/index.blade.php @@ -46,7 +46,7 @@