The ways supposed to be
This commit is contained in:
parent
3055c2f550
commit
903ca36b7b
|
@ -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";
|
||||
}elseif ($days >= 8 && $days <= 14){
|
||||
$bg = "warning";
|
||||
}elseif ($days <= 7){
|
||||
$bg = "danger";
|
||||
}
|
||||
|
||||
echo '
|
||||
<div class="col-12 col-sm-6 col-md-3">
|
||||
<div class="info-box mb-3">
|
||||
<span class="info-box-icon bg-'.$bg.' elevation-1">
|
||||
<i class="fas fa-hourglass-half"></i></span>
|
||||
<div class="info-box-content">
|
||||
<span class="info-box-text">Out of '. Configuration::getValueByKey('CREDITS_DISPLAY_NAME').' in </span>';
|
||||
//IF TIME IS LESS THAN 1 DAY CHANGE TO "hours"
|
||||
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>';
|
||||
if($days >= 15){
|
||||
$bg = "success";
|
||||
}elseif ($days >= 8 && $days <= 14){
|
||||
$bg = "warning";
|
||||
}elseif ($days <= 7){
|
||||
$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
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -70,9 +70,18 @@
|
|||
</div>
|
||||
|
||||
<!-- /.col -->
|
||||
{{ HomeController::CreditsLeftBox() }}
|
||||
@if(Auth::user()->Credits() > 0.01 and $useage > 0)
|
||||
<div class="col-12 col-sm-6 col-md-3">
|
||||
<div class="info-box mb-3">
|
||||
<span class="info-box-icon bg-{{$bg}} elevation-1">
|
||||
<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>
|
||||
<span class="info-box-number">{{$boxText}}<sup>{{$unit}}</sup></span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.info-box -->
|
||||
|
||||
@endif
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
|
||||
|
@ -80,6 +89,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="card card-default">
|
||||
|
|
Loading…
Reference in a new issue