Browse Source

update: fix

tokumeikoi 2 years ago
parent
commit
346d0222f5
2 changed files with 4 additions and 4 deletions
  1. 3 3
      app/Http/Controllers/User/PlanController.php
  2. 1 1
      app/Services/PlanService.php

+ 3 - 3
app/Http/Controllers/User/PlanController.php

@@ -43,9 +43,9 @@ class PlanController extends Controller
             ->get();
         if (isset($counts)) {
             foreach ($plans as $k => $v) {
-                if (isset($counts[$plans[$k]->id])) {
-                    $plans[$k]->capacity_limit = $plans[$k]->capacity_limit - $counts[$plans[$k]->id]->count;
-                }
+                if ($plans[$k]->capacity_limit === NULL) continue;
+                if (!isset($counts[$plans[$k]->id])) continue;
+                $plans[$k]->capacity_limit = $plans[$k]->capacity_limit - $counts[$plans[$k]->id]->count;
             }
         }
         return response([

+ 1 - 1
app/Services/PlanService.php

@@ -16,7 +16,7 @@ class PlanService
 
     public function haveCapacity(): bool
     {
-        if ($this->plan->capacity_limit === 0) return true;
+        if ($this->plan->capacity_limit === NULL) return true;
         $count = User::where('plan_id', $this->plan->plan_id)->count();
         return $this->plan->capacity_limit - $count;
     }