Browse Source

update: add inventory limit

tokumeikoi 2 years ago
parent
commit
aa65440556
1 changed files with 6 additions and 8 deletions
  1. 6 8
      app/Services/PlanService.php

+ 6 - 8
app/Services/PlanService.php

@@ -13,17 +13,15 @@ class PlanService
         $this->plan = Plan::lockForUpdate()->find($planId);
     }
 
-    public function incrementInventory()
+    public function incrementInventory(): bool
     {
-        if ($this->plan->inventory_limit !== NULL) {
-            return $this->plan->increment('inventory_limit');
-        }
+        if ($this->plan->inventory_limit !== NULL) return true;
+        return $this->plan->increment('inventory_limit');
     }
 
-    public function decrementInventory()
+    public function decrementInventory(): bool
     {
-        if ($this->plan->inventory_limit !== NULL) {
-            return $this->plan->decrement('inventory_limit');
-        }
+        if ($this->plan->inventory_limit !== NULL) return true;
+        return $this->plan->decrement('inventory_limit');
     }
 }