diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index b2c4384a..bafa8fac 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -20,57 +20,52 @@ class HomeController extends Controller
public function index(Request $request)
{
$usage = 0;
+ $bg="";
+ $boxText="";
+ $unit = "";
foreach (Auth::user()->servers as $server){
$usage += $server->product->price;
}
-
- return view('home')->with([
- 'useage' => $usage,
- 'useful_links' => UsefulLink::all()->sortBy('id')
- ]);
- }
-
- public static function CreditsLeftBox(){
- $usage = 0;
-
- foreach (Auth::user()->servers as $server){
- $usage += $server->product->price;
- }
-
if(Auth::user()->Credits() > 0.01 and $usage > 0){
$days = number_format((Auth::user()->Credits()*30)/$usage,2,'.','');
$hours = number_format(Auth::user()->Credits()/($usage/30/24),2,'.','');
+
if($days >= 15){
- $bg = "success";
+ $bg = "success";
}elseif ($days >= 8 && $days <= 14){
- $bg = "warning";
+ $bg = "warning";
}elseif ($days <= 7){
- $bg = "danger";
- }
-
- echo '
-
-
-
-
-
- Out of '. Configuration::getValueByKey('CREDITS_DISPLAY_NAME').' in ';
- //IF TIME IS LESS THAN 1 DAY CHANGE TO "hours"
- if($days < "1"){
- if($hours < "1"){
- echo 'You ran out of Credits ';
- }
- else{
- echo ' '.$hours.' hours';
- }
- }else{
- echo ''.number_format($days,0).' days';
- }
- }
- echo'
-
-
';
+ $bg = "danger";
}
+
+ if($days < "1"){
+ if($hours < "1"){
+ $boxText = 'You ran out of Credits ';
+ }
+ else{
+ $boxText = $hours;
+ $unit = "hours";
+ }
+ }else{
+ $boxText = number_format($days,0);
+ $unit = "days";
+ }
+ }
+
+
+ return view('home')->with([
+ 'useage' => $usage,
+ 'useful_links' => UsefulLink::all()->sortBy('id'),
+ 'bg' => $bg,
+ 'boxText' => $boxText,
+ 'unit' => $unit
+ ]);
}
+
+
+
+}
+
+
diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php
index 9ec07792..c109075e 100644
--- a/resources/views/home.blade.php
+++ b/resources/views/home.blade.php
@@ -70,9 +70,18 @@
- {{ HomeController::CreditsLeftBox() }}
+ @if(Auth::user()->Credits() > 0.01 and $useage > 0)
+
+
+
+
+
+ Out of {{CREDITS_DISPLAY_NAME}} in
+ {{$boxText}}{{$unit}}
+
+
-
+ @endif
@@ -80,6 +89,7 @@
+