Browse Source

update select customer role

pull/1/head
wahyuun 1 year ago
parent
commit
f7bb82f792
  1. 27
      app/Http/Controllers/ProjectController.php

27
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);

Loading…
Cancel
Save