From b79f558b40dac10e028dd5c1684d0b1609e120a8 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Fri, 23 Jun 2023 14:58:24 +0700 Subject: [PATCH] Fix successor duration --- app/Models/VersionGantt.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/Models/VersionGantt.php b/app/Models/VersionGantt.php index 0784bbe..05abbf6 100644 --- a/app/Models/VersionGantt.php +++ b/app/Models/VersionGantt.php @@ -4,6 +4,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; use App\Models\Activity; +use App\Models\Link; use DateTime; class VersionGantt extends Model @@ -47,9 +48,13 @@ class VersionGantt extends Model } $activities = Activity::where('version_gantt_id', $this->id)->get(); foreach ($activities as $value) { + $exist = Link::where('t_activity_id', $value->id)->exists(); $startDate = new DateTime($value->start_date); $endDate = new DateTime($value->end_date); $duration = $endDate->diff($startDate)->days + 1; + if ($exist) { + $duration--; + } // Iterate through each day and subtract the days off for ($i = 0; $i < $duration; $i++) {