diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index bb6838f3..aa979a65 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Models\UsefulLink;
+use App\Models\Configuration;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
@@ -13,6 +14,8 @@ class HomeController extends Controller
$this->middleware('auth');
}
+
+
/** Show the application dashboard. */
public function index(Request $request)
{
@@ -27,4 +30,47 @@ class HomeController extends Controller
'useful_links' => UsefulLink::all()->sortBy('id')
]);
}
+
+ public static function CreditsLeftBox(){
+ $usage = 0;
+ $CREDITS_DISPLAY_NAME = Configuration::getValueByKey('CREDITS_DISPLAY_NAME');
+ 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,'.','');
+ echo '
+
+
';
+ if($Days >= 15){
+ echo '
';
+ }
+ elseif ($Days >= 8 && $Days <= 14){
+ echo '';
+ }
+ elseif ($Days <= 7){
+ echo '';
+ }
+
+ echo '
+
+
+ Out of '.$CREDITS_DISPLAY_NAME.' in ';
+ if($Days < "1"){
+ if($Hours < "1"){
+ echo 'You ran out of Credits ';
+ }
+ else{
+ echo ' '.$Hours.' hours';
+ }
+ }else{
+ echo ''.number_format($Days,0).' days';
+ }
+ }
+ echo'
+
+ ';
+ }
}
diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php
index 50b2d0db..9ec07792 100644
--- a/resources/views/home.blade.php
+++ b/resources/views/home.blade.php
@@ -1,5 +1,8 @@
+
+
@extends('layouts.main')
+
@section('content')
- @if(Auth::user()->Credits() > 0.01 and $useage > 0)
-
-
- @if(number_format((Auth::user()->Credits()*30)/$useage,0,'.','') >= 15)
-
- @elseif (number_format((Auth::user()->Credits()*30)/$useage,0,'.','') >= 8 && number_format((Auth::user()->Credits()*30)/$useage,0,'.','') <= 14)
-
- @elseif (number_format((Auth::user()->Credits()*30)/$useage,0,'.','') <= 7)
-
- @endif
-
-
-
- Out of {{CREDITS_DISPLAY_NAME}} in
- @if(number_format((Auth::user()->Credits()*30)/$useage,2,'.','') < "1")
- @if(number_format(Auth::user()->Credits()/($useage/30/24),2,'.','') < "1")
- You ran out of Credits
- @else
- {{number_format(Auth::user()->Credits()/($useage/30/24),0,'.','')}} hours
- @endif
- @else
- {{number_format((Auth::user()->Credits()*30)/$useage,0,'.','')}} days
- @endif
-
-
-
+ {{ HomeController::CreditsLeftBox() }}
+
- @endif
+