Răsfoiți Sursa

:fire: array_find

visuddhinanda 9 luni în urmă
părinte
comite
944995b279
1 a modificat fișierele cu 9 adăugiri și 0 ștergeri
  1. 9 0
      api-v8/app/Http/Controllers/ProjectTreeController.php

+ 9 - 0
api-v8/app/Http/Controllers/ProjectTreeController.php

@@ -61,9 +61,18 @@ class ProjectTreeController extends Controller
         }
         foreach ($newData as $key => $value) {
             if ($value['parent_id']) {
+                $parent = null;
+                /*
                 $parent = \array_find($newData, function ($element) use ($value) {
                     return $element['old_id'] == $value['parent_id'];
                 });
+                */
+                foreach ($newData as $item) {
+                    if ($item['old_id'] == $value['parent_id']) {
+                        $parent = $item;
+                        break;
+                    }
+                }
                 if ($parent) {
                     $newData[$key]['parent_id'] = $parent['uid'];
                     $parentPath = $parent['path'] ? json_decode($parent['path']) : [];