From f7bb82f792f5f1f0354cc830b04cb99fba6bbf86 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Fri, 8 Dec 2023 15:16:59 +0700 Subject: [PATCH] update select customer role --- app/Http/Controllers/ProjectController.php | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 3015327..ff9a3cf 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -503,20 +503,29 @@ class ProjectController extends Controller return response()->json(['status' => 'success', 'data' => $response, 'code' => 200], 200); } - public function getByUser($id) - { - $alias = "utp"; + public function getByUser($id) { $userProyek = UserToProyek::query() - ->from('assign_hr_to_proyek AS ' . $alias) + ->from('assign_hr_to_proyek AS ahtp') ->where([ ['is_customer', true], ['user_id', $id] ]) - ->leftJoin('m_users', $alias . '.user_id', '=', 'm_users.id') - ->leftJoin('m_proyek', $alias . '.proyek_id', '=', 'm_proyek.id') - ->leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id') - ->select('m_proyek.*', 'm_type_proyek.name AS join_second_name', 'm_users.name AS join_first_name') - ->get(); + ->leftJoin('m_users', 'ahtp.user_id', '=', 'm_users.id') + ->leftJoin('m_proyek AS mp', 'ahtp.proyek_id', '=', 'mp.id') + ->leftJoin('m_type_proyek', 'mp.type_proyek_id', '=', 'm_type_proyek.id') + ->select( + 'mp.id', + 'mp.nama', + 'mp.rencana_biaya', + 'mp.type_proyek_id', + 'mp.currency_symbol', + 'mp.mulai_proyek', + 'mp.akhir_proyek', + 'm_users.name AS join_first_name', + 'm_users.username AS join_first_username', + 'm_type_proyek.name AS join_second_name', + 'm_type_proyek.name AS join_second_description' + )->get(); $totalRecord = $userProyek->count(); return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200);