Browse Source

Merge pull request 'update select customer role' (#22) from dev-wahyun into staging

Reviewed-on: ibnu/generic-ospro-backend#22
pull/1/head
farhantock 1 year ago
parent
commit
e0ef133431
  1. 27
      app/Http/Controllers/ProjectController.php

27
app/Http/Controllers/ProjectController.php

@ -510,20 +510,29 @@ class ProjectController extends Controller
return response()->json(['status' => 'success', 'data' => $response, 'code' => 200], 200); return response()->json(['status' => 'success', 'data' => $response, 'code' => 200], 200);
} }
public function getByUser($id) public function getByUser($id) {
{
$alias = "utp";
$userProyek = UserToProyek::query() $userProyek = UserToProyek::query()
->from('assign_hr_to_proyek AS ' . $alias) ->from('assign_hr_to_proyek AS ahtp')
->where([ ->where([
['is_customer', true], ['is_customer', true],
['user_id', $id] ['user_id', $id]
]) ])
->leftJoin('m_users', $alias . '.user_id', '=', 'm_users.id') ->leftJoin('m_users', 'ahtp.user_id', '=', 'm_users.id')
->leftJoin('m_proyek', $alias . '.proyek_id', '=', 'm_proyek.id') ->leftJoin('m_proyek AS mp', 'ahtp.proyek_id', '=', 'mp.id')
->leftJoin('m_type_proyek', 'm_proyek.type_proyek_id', '=', 'm_type_proyek.id') ->leftJoin('m_type_proyek', 'mp.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') ->select(
->get(); '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(); $totalRecord = $userProyek->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200);

Loading…
Cancel
Save