Explorar el Código

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

kely hace 8 meses
padre
commit
919fd7830e
Se han modificado 1 ficheros con 3 adiciones y 0 borrados
  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();