Browse Source

Merge pull request 'dev-wahyun' (#178) from dev-wahyun into staging

Reviewed-on: ordo/adw-backend#178
pull/3/head
ibnu 1 year ago
parent
commit
365b74fdd9
  1. 19
      app/Http/Controllers/ProjectController.php
  2. 3
      routes/web.php

19
app/Http/Controllers/ProjectController.php

@ -442,7 +442,24 @@ class ProjectController extends Controller
// return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200);
return response()->json(['status'=>'success', 'data'=> '', 'code'=>200], 200);
}
public function getByUser($id)
{
$alias = "utp";
$userProyek = UserToProyek::query()
->from('assign_hr_to_proyek AS ' . $alias)
->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();
$totalRecord = $userProyek->count();
return response()->json(['status' => 'success', 'code' => 200, 'data' => $userProyek, 'totalRecord' => $totalRecord], 200);
}
public function detail($id){
if(empty($id) || !is_int((int)$id))
return response()->json(['status'=>'failed','message'=>'id is required!','code'=>400], 400);

3
routes/web.php

@ -1,7 +1,7 @@
<?php
$router->get('/', function () use ($router) {
return $router->app->version();
return $router->app->version();
});
$router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($router) {
@ -53,6 +53,7 @@ $router->group(['prefix'=>'api', 'middleware' => 'cors'], function () use ($rout
$router->post('/document-activity/search', 'ActivityDokumenController@searchDocProject');
$router->get('/document-activity/download/{id}', 'ActivityDokumenController@downloadDokumen');
$router->get('/project-by-customer/{id}','ProjectController@getByUser');
$router->post('/project/search', 'ProjectController@search');
$router->post('/project/add', 'ProjectController@add');
$router->put('/project/update/{id}', 'ProjectController@update');

Loading…
Cancel
Save