Browse Source

Merge pull request 'staging' (#180) from staging into master

Reviewed-on: ordo/adw-backend#180
pull/3/head
ibnu 1 year ago
parent
commit
e1b8d89558
  1. 13
      app/Http/Controllers/BroadcastController.php
  2. 22
      app/Http/Controllers/ProjectController.php
  3. 3
      routes/web.php

13
app/Http/Controllers/BroadcastController.php

@ -15,6 +15,12 @@ class BroadcastController extends Controller
$data = $request->all();
$data['status_send'] = true;
$data['created_by'] = $this->currentName;
if (isset($data['send_to_id'])) {
$idArray = $data['send_to_id'];
if (is_array($data['send_to_id'])) {
$data['send_to_id'] = implode(", ", $idArray);
}
}
// dd($data);
$result = Broadcast::create($data);
if($result){
@ -140,8 +146,10 @@ class BroadcastController extends Controller
}
break;
case 'user':
$user = User::where("id", $data['send_to_id'])->whereNotNull('fcm_token')->first();
case 'users':
$idArray = explode(", ", $data['send_to_id']);
foreach ($idArray as $key => $value) {
$user = User::where("id", $value)->whereNotNull('fcm_token')->first();
if (isset($user)) {
FCMService::send(
$user->fcm_token,
@ -151,6 +159,7 @@ class BroadcastController extends Controller
]
);
}
}
break;
default:

22
app/Http/Controllers/ProjectController.php

@ -439,10 +439,26 @@ class ProjectController extends Controller
$response = MasterFunctionsHelper::curlReq($url);
// return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200);
return response()->json(['status'=>'success', 'data'=> '', 'code'=>200], 200);
return response()->json(['status'=>'success', 'data'=> $response, '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