Beautify
This commit is contained in:
parent
a024d7ce6a
commit
46173d7bfb
|
@ -8,11 +8,65 @@ use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
class HomeController extends Controller
|
class HomeController extends Controller
|
||||||
{
|
{
|
||||||
|
const TIME_LEFT_BG_SUCCESS = "bg-success";
|
||||||
|
const TIME_LEFT_BG_WARNING = "bg-warning";
|
||||||
|
const TIME_LEFT_BG_DANGER = "bg-danger";
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->middleware('auth');
|
$this->middleware('auth');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get the Background Color for the Days-Left-Box in HomeView */
|
||||||
|
public function getTimeLeftBoxBackground($days){
|
||||||
|
switch($days){
|
||||||
|
case ($days >= 15):
|
||||||
|
return $this::TIME_LEFT_BG_SUCCESS;
|
||||||
|
break;
|
||||||
|
case ($days >= 8 && $days <= 14):
|
||||||
|
return $this::TIME_LEFT_BG_WARNING;
|
||||||
|
break;
|
||||||
|
case ($days <= 7):
|
||||||
|
return $this::TIME_LEFT_BG_DANGER;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return $this::TIME_LEFT_BG_WARNING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get the Text for the Days-Left-Box in HomeView */
|
||||||
|
public function getTimeLeftBoxText($days,$hours){
|
||||||
|
if ($days < 1)
|
||||||
|
{
|
||||||
|
if ($hours < 1)
|
||||||
|
{
|
||||||
|
return 'You ran out of Credits ';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $hours;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return number_format($days, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTimeLeftUnit($days){
|
||||||
|
switch($days){
|
||||||
|
case ($days < 1):
|
||||||
|
return "hours";
|
||||||
|
break;
|
||||||
|
case ($days > 1):
|
||||||
|
return "days";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return "days";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Show the application dashboard. */
|
/** Show the application dashboard. */
|
||||||
public function index(Request $request)
|
public function index(Request $request)
|
||||||
{
|
{
|
||||||
|
@ -22,44 +76,16 @@ class HomeController extends Controller
|
||||||
$boxText = "";
|
$boxText = "";
|
||||||
$unit = "";
|
$unit = "";
|
||||||
|
|
||||||
// START OF THE TIME-REMAINING-BOX
|
/** Build our Time-Left-Box */
|
||||||
if ($credits > 0.01 and $usage > 0)
|
if ($credits > 0.01 and $usage > 0)
|
||||||
{
|
{
|
||||||
$days = number_format(($credits * 30) / $usage, 2, '.', '');
|
$days = number_format(($credits * 30) / $usage, 2, '.', '');
|
||||||
$hours = number_format($credits / ($usage / 30 / 24) , 2, '.', '');
|
$hours = number_format($credits / ($usage / 30 / 24) , 2, '.', '');
|
||||||
|
|
||||||
// DEFINE THE BACKGROUND COLOR
|
$bg = $this->getTimeLeftBoxBackground($days);
|
||||||
if ($days >= 15)
|
$boxText = $this->getTimeLeftBoxText($days,$hours);
|
||||||
{
|
$unit = $this->getTimeLeftUnit($days,$hours);
|
||||||
$bg = "success";
|
|
||||||
}
|
|
||||||
elseif ($days >= 8 && $days <= 14)
|
|
||||||
{
|
|
||||||
$bg = "warning";
|
|
||||||
}
|
|
||||||
elseif ($days <= 7)
|
|
||||||
{
|
|
||||||
$bg = "danger";
|
|
||||||
}
|
|
||||||
|
|
||||||
// DEFINE WETHER DAYS OR HOURS REMAIN
|
|
||||||
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 ALL VALUES
|
// RETURN ALL VALUES
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
@if($credits > 0.01 and $useage > 0)
|
@if($credits > 0.01 and $useage > 0)
|
||||||
<div class="col-12 col-sm-6 col-md-3">
|
<div class="col-12 col-sm-6 col-md-3">
|
||||||
<div class="info-box mb-3">
|
<div class="info-box mb-3">
|
||||||
<span class="info-box-icon bg-{{$bg}} elevation-1">
|
<span class="info-box-icon {{$bg}} elevation-1">
|
||||||
<i class="fas fa-hourglass-half"></i></span>
|
<i class="fas fa-hourglass-half"></i></span>
|
||||||
<div class="info-box-content">
|
<div class="info-box-content">
|
||||||
<span class="info-box-text">Out of {{CREDITS_DISPLAY_NAME}} in </span>
|
<span class="info-box-text">Out of {{CREDITS_DISPLAY_NAME}} in </span>
|
||||||
|
|
Loading…
Reference in a new issue