Browse Source

update header if start / end date changed / an activity deleted

pull/3/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
459a0adc0c
  1. 7
      app/Models/Activity.php

7
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(); $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(); $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()) { if($header = Activity::where('version_gantt_id', $this->version_gantt_id)->whereNull('parent_id')->first()) {
$header->update([ $header->start_date = $earliestStartDate;
"start_date" => $earliestStartDate, $header->end_date = $latestEndDate;
"end_date" => $latestEndDate $header->saveQuietly();
]);
} }
} }

Loading…
Cancel
Save