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++) {