Fix
This commit is contained in:
parent
8ee876b30a
commit
ed3edd181b
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\UsefulLink;
|
use App\Models\UsefulLink;
|
||||||
|
use App\Models\Configuration;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
@ -13,6 +14,8 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -27,4 +30,47 @@ class HomeController extends Controller
|
||||||
'useful_links' => UsefulLink::all()->sortBy('id')
|
'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 '
|
||||||
|
<div class="col-12 col-sm-6 col-md-3">
|
||||||
|
<div class="info-box mb-3">';
|
||||||
|
if($Days >= 15){
|
||||||
|
echo '<span class="info-box-icon bg-success elevation-1">';
|
||||||
|
}
|
||||||
|
elseif ($Days >= 8 && $Days <= 14){
|
||||||
|
echo '<span class="info-box-icon bg-warning elevation-1">';
|
||||||
|
}
|
||||||
|
elseif ($Days <= 7){
|
||||||
|
echo '<span class="info-box-icon bg-danger elevation-1">';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo '<i class="fas fa-hourglass-half"></i></span>
|
||||||
|
|
||||||
|
<div class="info-box-content">
|
||||||
|
<span class="info-box-text">Out of '.$CREDITS_DISPLAY_NAME.' in </span>';
|
||||||
|
if($Days < "1"){
|
||||||
|
if($Hours < "1"){
|
||||||
|
echo '<span class="info-box-number">You ran out of Credits </span>';
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
echo '<span class="info-box-number"> '.$Hours.' <sup> hours</sup></span>';
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
echo '<span class="info-box-number">'.number_format($Days,0).' <sup> days</sup></span>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo'
|
||||||
|
</div>
|
||||||
|
</div> ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
|
|
||||||
|
|
||||||
@extends('layouts.main')
|
@extends('layouts.main')
|
||||||
|
|
||||||
|
<?php use App\Http\Controllers\HomeController; ?>
|
||||||
@section('content')
|
@section('content')
|
||||||
<!-- CONTENT HEADER -->
|
<!-- CONTENT HEADER -->
|
||||||
<section class="content-header">
|
<section class="content-header">
|
||||||
|
@ -67,36 +70,12 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- /.col -->
|
<!-- /.col -->
|
||||||
@if(Auth::user()->Credits() > 0.01 and $useage > 0)
|
{{ HomeController::CreditsLeftBox() }}
|
||||||
<div class="col-12 col-sm-6 col-md-3">
|
|
||||||
<div class="info-box mb-3">
|
|
||||||
@if(number_format((Auth::user()->Credits()*30)/$useage,0,'.','') >= 15)
|
|
||||||
<span class="info-box-icon bg-success elevation-1">
|
|
||||||
@elseif (number_format((Auth::user()->Credits()*30)/$useage,0,'.','') >= 8 && number_format((Auth::user()->Credits()*30)/$useage,0,'.','') <= 14)
|
|
||||||
<span class="info-box-icon bg-warning elevation-1">
|
|
||||||
@elseif (number_format((Auth::user()->Credits()*30)/$useage,0,'.','') <= 7)
|
|
||||||
<span class="info-box-icon bg-danger elevation-1">
|
|
||||||
@endif
|
|
||||||
<i class="fas fa-hourglass-half"></i></span>
|
|
||||||
|
|
||||||
<div class="info-box-content">
|
|
||||||
<span class="info-box-text">Out of {{CREDITS_DISPLAY_NAME}} in </span>
|
|
||||||
@if(number_format((Auth::user()->Credits()*30)/$useage,2,'.','') < "1")
|
|
||||||
@if(number_format(Auth::user()->Credits()/($useage/30/24),2,'.','') < "1")
|
|
||||||
<span class="info-box-number">You ran out of Credits </span>
|
|
||||||
@else
|
|
||||||
<span class="info-box-number">{{number_format(Auth::user()->Credits()/($useage/30/24),0,'.','')}} <sup> hours</sup></span>
|
|
||||||
@endif
|
|
||||||
@else
|
|
||||||
<span class="info-box-number">{{number_format((Auth::user()->Credits()*30)/$useage,0,'.','')}} <sup> days</sup></span>
|
|
||||||
@endif
|
|
||||||
</div>
|
|
||||||
<!-- /.info-box-content -->
|
|
||||||
</div>
|
|
||||||
<!-- /.info-box -->
|
<!-- /.info-box -->
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- /.col -->
|
<!-- /.col -->
|
||||||
@endif
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue