From 69ea8e83e31299e4edb09ece869889dc58046d9d Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 13 Dec 2022 15:18:59 +0700 Subject: [PATCH] update header if start / end date changed / an activity deleted --- app/Models/Activity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 60cb164..0d55312 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -166,8 +166,8 @@ class Activity extends Model private function updateStartEndDateHeader() { - $earliestStartDate = Activity::where('version_gantt_id', $this->version_gantt_id)->oldest('start_date')->pluck('start_date')->first(); - $latestEndDate = Activity::where('version_gantt_id', $this->version_gantt_id)->latest('end_date')->pluck('end_date')->first(); + $earliestStartDate = Activity::where('version_gantt_id', $this->version_gantt_id)->whereNotNull('parent_id')->oldest('start_date')->pluck('start_date')->first(); + $latestEndDate = Activity::where('version_gantt_id', $this->version_gantt_id)->whereNotNull('parent_id')->latest('end_date')->pluck('end_date')->first(); if($header = Activity::where('version_gantt_id', $this->version_gantt_id)->whereNull('parent_id')->first()) { $header->update([ "start_date" => $earliestStartDate,