This commit is contained in:
1day2die 2021-10-26 17:55:55 +02:00
parent fe588c5069
commit a2e4798b3d

View file

@ -1,5 +1,4 @@
<?php <?php
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\UsefulLink; use App\Models\UsefulLink;
@ -14,42 +13,51 @@ class HomeController extends Controller
$this->middleware('auth'); $this->middleware('auth');
} }
/** Show the application dashboard. */ /** Show the application dashboard. */
public function index(Request $request) public function index(Request $request)
{ {
$usage = Auth::user()->creditUsage(); $usage = Auth::user()->creditUsage();
$credits = Auth::user()->Credits(); $credits = Auth::user()->Credits();
$bg=""; $bg = "";
$boxText=""; $boxText = "";
$unit = ""; $unit = "";
// START OF THE TIME-REMAINING-BOX // START OF THE TIME-REMAINING-BOX
if($credits > 0.01 and $usage > 0){ if ($credits > 0.01 and $usage > 0)
$days = number_format(($credits*30)/$usage,2,'.',''); {
$hours = number_format($credits/($usage/30/24),2,'.',''); $days = number_format(($credits * 30) / $usage, 2, '.', '');
$hours = number_format($credits / ($usage / 30 / 24) , 2, '.', '');
// DEFINE THE BACKGROUND COLOR // DEFINE THE BACKGROUND COLOR
if($days >= 15){ if ($days >= 15)
{
$bg = "success"; $bg = "success";
}elseif ($days >= 8 && $days <= 14){ }
elseif ($days >= 8 && $days <= 14)
{
$bg = "warning"; $bg = "warning";
}elseif ($days <= 7){ }
elseif ($days <= 7)
{
$bg = "danger"; $bg = "danger";
} }
// DEFINE WETHER DAYS OR HOURS REMAIN // DEFINE WETHER DAYS OR HOURS REMAIN
if($days < "1"){ if ($days < "1")
if($hours < "1"){ {
if ($hours < "1")
{
$boxText = 'You ran out of Credits '; $boxText = 'You ran out of Credits ';
} }
else{ else
{
$boxText = $hours; $boxText = $hours;
$unit = "hours"; $unit = "hours";
} }
}else{ }
$boxText = number_format($days,0); else
{
$boxText = number_format($days, 0);
$unit = "days"; $unit = "days";
} }
} }
@ -62,10 +70,7 @@ class HomeController extends Controller
'boxText' => $boxText, 'boxText' => $boxText,
'unit' => $unit 'unit' => $unit
]); ]);
} }
} }