From 2aed8364ab732760e4ca13c96b82e6d0ea4b1a12 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Fri, 25 Aug 2023 11:19:36 +0700 Subject: [PATCH] Fix getactivity first and last --- app/Http/Controllers/ActivityController.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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;