From 07a14558933cb04d9bfa253e709ad4c1485e6d68 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Tue, 5 Dec 2023 08:24:08 +0700 Subject: [PATCH] update endpoint --- .../ProjectCarausellController.php | 39 ++++++------------- 1 file changed, 11 insertions(+), 28 deletions(-) diff --git a/app/Http/Controllers/ProjectCarausellController.php b/app/Http/Controllers/ProjectCarausellController.php index 2850318..e64aca9 100644 --- a/app/Http/Controllers/ProjectCarausellController.php +++ b/app/Http/Controllers/ProjectCarausellController.php @@ -16,34 +16,19 @@ class ProjectCarausellController extends Controller $projectData = Project::query() ->select("id","nama","kode_sortname","pm_id","budget_health","calculation_status","mulai_proyek","akhir_proyek","rencana_biaya","company","scurve") ->get(); - $projectRisk = ProjectRisks::query() - ->select('proyek_id','description','level_risk','preventive_risk') - ->get(); - $projectIssue = ProjectIssues::query() - ->select('proyek_id','description','level_issue') - ->get(); $arr = []; foreach($projectData as $project) { - $riskProject = []; - $issueProject = []; - foreach ($projectRisk as $risk) { - if ($risk['proyek_id'] === $project['id']) { - $riskProject[] = [ - 'level_risk' => $risk['level_risk'], - 'preventive_risk' => $risk['preventive_risk'], - 'description' => $risk['description'] - ]; - } - } - foreach ($projectIssue as $issue) { - if ($issue['proyek_id'] === $project['id']) { - $issueProject[] = [ - 'level_issue' => $issue['level_issue'], - 'description' => $issue['description'] - ]; - } - } + $projectRisk = ProjectRisks::query() + ->select('proyek_id','description','level_risk','preventive_risk') + ->where('proyek_id', $project['id']) + ->get() + ->toArray(); + $projectIssue = ProjectIssues::query() + ->select('proyek_id','description','level_issue') + ->where('proyek_id',$project['id']) + ->get() + ->toArray(); $ganttData = VersionGantt::query() ->select('id', 'name_version','hierarchy_ftth_id','cost_to_complete','proyek_id','calculation_type') ->where('proyek_id',$project['id']) @@ -63,11 +48,9 @@ class ProjectCarausellController extends Controller "rencana_biaya" => $project['rencana_biaya'], "company" => $project['company'], "scurve" => $project['scurve'], - "project_risk" => $riskProject, - "project_issues" => $issueProject ], "project_manager" => $projectManager, - "project_risk" => $riskProject, + "project_risk" => $projectRisk, "project_issue" => $projectIssue, "gantt"=> $ganttData ];