diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 401837e..3b8ff84 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -151,7 +151,10 @@ class ActivityController extends Controller } public function getActivityFirst($parentId){ - $activity = Activity::where('parent_id', $parentId)->orderByRaw('start_date ASC')->first(); + $activity = Activity::where('parent_id', $parentId)->orderByRaw('actual_start ASC')->first(); + if (!isset($activity)) { + return null; + } if($activity->type_activity == "task"){ // Log::info("activity ", [$activity]); return $activity->actual_start; @@ -162,7 +165,10 @@ class ActivityController extends Controller } public function getActivityLast($parentId){ - $activity = Activity::where('parent_id', $parentId)->orderByRaw('start_date DESC')->first(); + $activity = Activity::where('parent_id', $parentId)->orderByRaw('actual_end DESC')->first(); + if (!isset($activity)) { + return null; + } if($activity->type_activity == "task"){ // Log::info("activity ", [$activity]); return $activity->actual_end;