From 4b9da555b15f23fb9452ac96b2ae82d91550c549 Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 29 Nov 2022 18:31:54 +0700 Subject: [PATCH] temp: calc up bobot planning --- app/Models/Activity.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index b8da186..cc4beb1 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -87,8 +87,14 @@ class Activity extends Model $activity->saveQuietly(); } + } else { + if($parent = Activity::find($this->parent_id)){ + $totalChildWeight = Activity::where("parent_id", $this->parent_id)->sum('bobot_planning'); + $parent->update([ + "bobot_planning" => $totalChildWeight + ]); + } } - } private function updateCostActual()