Browse Source

Fix "You Ran out of Credits - hours"

WBLKLeipe 3 years ago
parent
commit
14bceeb311
1 changed files with 25 additions and 1 deletions
  1. 25 1
      app/Http/Controllers/HomeController.php

+ 25 - 1
app/Http/Controllers/HomeController.php

@@ -48,6 +48,30 @@ class HomeController extends Controller
         }
     }
 
+    /**
+    * @description Set "hours", "days" or nothing behind the remaining time
+    *
+    * @param  float  $days
+    * @param  float  $hours
+    *
+    * @return string
+    */
+    public function getTimeLeftBoxUnit(float $days, float $hours)
+    {
+        if ($days < 1)
+        {
+            if ($hours < 1)
+            {
+                return;
+            }
+            else
+            {
+                return "hours";
+            }
+        }
+        return "days";
+    }
+
     /**
     * @description Get the Text for the Days-Left-Box in HomeView
     *
@@ -89,7 +113,7 @@ class HomeController extends Controller
 
             $bg = $this->getTimeLeftBoxBackground($days);
             $boxText = $this->getTimeLeftBoxText($days, $hours);
-            $unit = $days < 1 ? 'hours' : 'days';
+            $unit = $this->getTimeLeftBoxUnit($days, $hours);
 
         }