Browse Source

删除计划时必须先删除子计划

kely 7 months ago
parent
commit
919fd7830e
1 changed files with 3 additions and 0 deletions
  1. 3 0
      app/Http/Controllers/API/PlanController.php

+ 3 - 0
app/Http/Controllers/API/PlanController.php

@@ -120,6 +120,9 @@ class PlanController extends Controller
     public function destroy(string $id)
     {
         $plan = Plan::findOrFail($id);
+        if(!empty($plan->children()->first())){
+            throw new \Exception("Please remove the sub-level plan.");
+        }
 
         $plan->delete();