From 7233afaa697c62346e4db2b453f1e6830d844a28 Mon Sep 17 00:00:00 2001 From: wahyu Date: Mon, 16 Oct 2023 13:31:52 +0700 Subject: [PATCH 1/2] fix endline --- app/Models/Role.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/app/Models/Role.php b/app/Models/Role.php index 3c0f409..0363567 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -1,17 +1,17 @@ - Date: Mon, 16 Oct 2023 13:56:22 +0700 Subject: [PATCH 2/2] update recursive --- app/Http/Controllers/ActivityController.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 5655cdb..acd94b0 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -175,6 +175,7 @@ class ActivityController extends Controller }else{ $data = Activity::select('id', 'parent_id', 'name', 'actual_end')->where('parent_id', $id)->get(); } + $parent = Activity::findOrFail($id); $dataFinal=[]; foreach ($data as $val) { $activity = $this->getchildActivityForActual($val->id, $params); @@ -187,11 +188,19 @@ class ActivityController extends Controller return isset($item['actual_start']); }), 'actual_start'); $returnActualStartOrEnd = count($actualStartValues) == count($dataFinal) ? min($actualStartValues) : null; + if (isset($parent)) { + $parent->actual_start = $returnActualStartOrEnd; + $parent->save(); + } }else{ $actualEndValues = array_column(array_filter($dataFinal, function($item) { return isset($item['actual_end']); }), 'actual_end'); $returnActualStartOrEnd = count($actualEndValues) == count($dataFinal) ? max($actualEndValues) : null; + if (isset($parent)) { + $parent->actual_end = $returnActualStartOrEnd; + $parent->save(); + } } // return json_encode(["min"=>$minActualStart, "max"=>$maxActualStart]);