From 459a0adc0ca4a4d3673675ef0ba6d34197bbba6a Mon Sep 17 00:00:00 2001 From: Muhammad Sulaiman Yusuf Date: Tue, 13 Dec 2022 15:31:36 +0700 Subject: [PATCH] update header if start / end date changed / an activity deleted --- app/Models/Activity.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/Models/Activity.php b/app/Models/Activity.php index 0d55312..9be182c 100644 --- a/app/Models/Activity.php +++ b/app/Models/Activity.php @@ -169,10 +169,9 @@ class Activity extends Model $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, - "end_date" => $latestEndDate - ]); + $header->start_date = $earliestStartDate; + $header->end_date = $latestEndDate; + $header->saveQuietly(); } }