Exemple #1
0
 public static function ofProject(Project $project, $time = null, $direction = self::BEFORE)
 {
     $activities = self::feed($project->activities(), $time, $direction, 8);
     $comments = self::feed($project->comments(), $time, $direction, 8);
     if ($activities->count() && $comments->count()) {
         $last_activity = $activities->last()->created_at;
         $last_comment = $comments->last()->created_at;
         $condition = $direction == self::BEFORE ? $last_activity > $last_comment : $last_activity < $last_comment;
         $interval = [$last_comment, $last_activity];
         if ($direction != self::BEFORE) {
             $interval = array_reverse($interval);
         }
         if ($condition) {
             $activities = $activities->merge($project->activities()->whereBetween('created_at', $interval)->get());
         } else {
             $comments = $comments->merge($project->comments()->whereBetween('created_at', array_reverse($interval))->get());
         }
     }
     $feed = (new Collection($activities))->merge($comments);
     $feed = $feed->sort(function ($a, $b) {
         return $a->created_at < $b->created_at;
     });
     return $feed;
 }
 public function chart(Project $project)
 {
     $tasks = Task::getGanttHierarchy($project->tasks(true)->get());
     $path = new CriticalPath($tasks);
     $dates = [];
     for ($cursor = $project->from; $cursor->lte($project->to); $cursor = $cursor->addDay()) {
         $dates[] = $cursor->format('Y-m-d');
     }
     //dd($path->GetChart());
     return view('manage/chart', ['dates' => $dates, 'tasks' => $path->GetChart(), 'project' => $project]);
 }