Browse Source

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

Reviewed-on: ibnu/generic-ospro-backend#56
pull/1/head
farhantock 10 months ago
parent
commit
e6503c134d
  1. 2
      app/Http/Controllers/Controller.php
  2. 10
      app/Http/Controllers/HumanResourceController.php
  3. 34
      app/Http/Controllers/ProductTransactionController.php
  4. 2
      app/Http/Controllers/RefferalCodeController.php
  5. 1
      app/Models/HumanResource.php
  6. 1
      app/Models/RefferalCode.php
  7. 9
      routes/web.php

2
app/Http/Controllers/Controller.php

@ -131,7 +131,7 @@ class Controller extends BaseController
return response()->json(['status' => 'failed', 'message' => 'Limited storage maximum!', 'code' => 500], 500); return response()->json(['status' => 'failed', 'message' => 'Limited storage maximum!', 'code' => 500], 500);
} }
} }
$resultMove = $dokumen->move($folderPath, $name); $resultMove = $dokumen->move($initPath, $name);
return [ return [
'resultMove' => $resultMove 'resultMove' => $resultMove

10
app/Http/Controllers/HumanResourceController.php

@ -119,11 +119,11 @@ class HumanResourceController extends Controller
if(empty($humanresource)) { if(empty($humanresource)) {
return response()->json(['status' => 'failed', 'message' => 'Data Human Resource not found!', 'code' => 400], 400); return response()->json(['status' => 'failed', 'message' => 'Data Human Resource not found!', 'code' => 400], 400);
} }
if($request->company_id && isset($request->password) && isset($request->username)) {
$transaction = ProductTransaction::query() $transaction = ProductTransaction::query()
->where('company_id', $request->company_id); ->where('company_id', $request->company_id);
$cloneQueryTransaction = clone $transaction; $cloneQueryTransaction = clone $transaction;
if($request->company_id && isset($request->password) && isset($request->username)) :
$countCreate = false; $countCreate = false;
$projectResult = HumanResource::query() $projectResult = HumanResource::query()
->selectRaw('count(*) as total_hr') ->selectRaw('count(*) as total_hr')
@ -144,7 +144,9 @@ class HumanResourceController extends Controller
} else { } else {
$countCreate = true; $countCreate = true;
} }
endif; } else {
$countCreate = true;
}
$request->ktp_number !== $humanresource['ktp_number'] ? $this->validate($request,['ktp_number'=>'unique:m_users,ktp_number|string']) : ''; $request->ktp_number !== $humanresource['ktp_number'] ? $this->validate($request,['ktp_number'=>'unique:m_users,ktp_number|string']) : '';
$request->email !== $humanresource['email'] ? $this->validate($request,['email'=>'unique:m_users,email|email']) : ''; $request->email !== $humanresource['email'] ? $this->validate($request,['email'=>'unique:m_users,email|email']) : '';
$request->password ? $this->validate($request,['password'=>'required|min:8']) : ''; $request->password ? $this->validate($request,['password'=>'required|min:8']) : '';
@ -166,7 +168,7 @@ class HumanResourceController extends Controller
} }
if ($result) { if ($result) {
return response()->json(['status' => 'success', 'message' => 'Human Resource Pool successfully updated!', 'code' => 200], 200); return response()->json(['status' => 'success', 'data' => $result, 'message' => 'Human Resource Pool successfully updated!', 'code' => 200], 200);
} else { } else {
return response()->json(['status' => 'failed', 'message' => 'Human Resource Pool failed updated!', 'code' => 400], 400); return response()->json(['status' => 'failed', 'message' => 'Human Resource Pool failed updated!', 'code' => 400], 400);
} }

34
app/Http/Controllers/ProductTransactionController.php

@ -24,14 +24,14 @@ class ProductTransactionController extends Controller
if ($result) { if ($result) {
return response()->json(['status' => 'success', 'data' => $result, 'message' => 'Add Transaction successfully!', 'code' => 200], 200); return response()->json(['status' => 'success', 'data' => $result, 'message' => 'Add Transaction successfully!', 'code' => 200], 200);
} else { } else {
return response()->json(['status' => 'failed', 'message' => 'Add data Transaction failed!', 'code' => 400], 400); return response()->json(['status' => 'failed', 'message' => 'Add Transaction failed!', 'code' => 400], 400);
} }
} }
public function edit($id) public function edit($id)
{ {
if (!$id || (int) $id < 0 || $id == "") { if (!$id || (int) $id < 0 || $id == "") {
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); return response()->json(['status' => 'failed', 'message' => 'Id is required!', 'code' => 400], 400);
die(); die();
} }
@ -40,50 +40,30 @@ class ProductTransactionController extends Controller
if ($result) { if ($result) {
return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else { } else {
return response()->json(['status' => 'failed', 'message' => 'failed get data Transaction, please try again later!', 'code' => 400], 400); return response()->json(['status' => 'failed', 'message' => 'Failed get data transaction, please try again later!', 'code' => 400], 400);
} }
} }
public function update(Request $request, $id) public function update(Request $request, $id)
{ {
if(!$id || (int) $id < 0 || $id==""){ if(!$id || (int) $id < 0 || $id==""){
return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400);
} }
$data = ProductTransaction::find($id); $data = ProductTransaction::find($id);
if($data){ if($data){
$result = $data->update($request->all()); $result = $data->update($request->all());
}else{ }else{
return response()->json(['status' => 'failed', 'message' => 'data Transaction not found!', 'code' => 400], 400); return response()->json(['status'=>'failed','message'=>'Data transaction not found!','code'=>400], 400);
die(); die();
} }
if($result){ if($result){
return response()->json(['status' => 'success', 'message' => 'data Transaction successfully updated!', 'code' => 200], 200); return response()->json(['status'=>'success','message'=>'Data transaction successfully updated!','code'=>200], 200);
} else {
return response()->json(['status' => 'failed', 'message' => 'data Transaction failed updated!', 'code' => 400], 400);
}
}
public function delete($id)
{
$data = ProductTransaction::find($id);
if ($data) {
$delete = $data->delete();
} else {
return response()->json(['status' => 'failed', 'message' => 'data Transaction not found!', 'code' => 400], 400);
die();
}
if ($delete) {
return response()->json(['status' => 'success', 'message' => 'data Transaction successfully deleted!', 'code' => 200], 200);
}else{ }else{
return response()->json(['status' => 'failed', 'message' => 'data Transaction failed deleted!', 'code' => 400], 400); return response()->json(['status'=>'failed','message'=>'Data transaction failed updated!','code'=>400], 400);
} }
} }

2
app/Http/Controllers/RefferalCodeController.php

@ -23,7 +23,7 @@ class RefferalCodeController extends Controller
$result = RefferalCode::create($data); $result = RefferalCode::create($data);
if($result){ if($result){
return response()->json(['status'=>'success','message'=>'Add refferal code successfully!','code'=>200], 200); return response()->json(['status'=>'success', 'data'=> $result, 'message'=>'Add refferal code successfully!','code'=>200], 200);
}else{ }else{
return response()->json(['status'=>'failed','message'=>'Add refferal Code failed!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'Add refferal Code failed!','code'=>400], 400);
} }

1
app/Models/HumanResource.php

@ -14,6 +14,7 @@ class HumanResource extends Model
protected $fillable = [ protected $fillable = [
'role_id', 'role_id',
'username', 'username',
'discount_id',
'password', 'password',
'session_login', 'session_login',
'name', 'name',

1
app/Models/RefferalCode.php

@ -12,7 +12,6 @@ class RefferalCode extends Model
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'id',
'code', 'code',
'amount', 'amount',
'exp', 'exp',

9
routes/web.php

@ -9,7 +9,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
// Landing Route // Landing Route
$router->post('/send-email', 'AuthController@sendEmail'); $router->post('/send-email', 'AuthController@sendEmail');
$router->post('/company-management-user/add', 'CompanyController@add'); $router->post('/company-management-user/add', 'CompanyController@add');
$router->post('/product-transaction/add', 'ProductTransactionController@add'); $router->post('/product-transaction-user/add', 'ProductTransactionController@add');
$router->post('/company-management-user/search', 'CompanyController@search'); $router->post('/company-management-user/search', 'CompanyController@search');
$router->post('/human-resource-user/add', 'HumanResourceController@add_user'); $router->post('/human-resource-user/add', 'HumanResourceController@add_user');
$router->get('/company-management-user/edit/{id}', 'CompanyController@edit'); $router->get('/company-management-user/edit/{id}', 'CompanyController@edit');
@ -17,7 +17,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->post('/role-user/add', 'RoleController@add'); $router->post('/role-user/add', 'RoleController@add');
$router->post('/menu-company-user/add-multiple', 'MenuCompanyController@addMultiple'); $router->post('/menu-company-user/add-multiple', 'MenuCompanyController@addMultiple');
$router->post('/role-menu-user/add-multiple', 'RoleMenuController@addMultiple'); $router->post('/role-menu-user/add-multiple', 'RoleMenuController@addMultiple');
$router->post('/refferal-code/search', 'RefferalCodeController@search'); $router->post('/refferal-code-user/search', 'RefferalCodeController@search');
$router->post('/menu/add', 'MenuController@add'); $router->post('/menu/add', 'MenuController@add');
$router->get('/menu/edit/{id}', 'MenuController@edit'); $router->get('/menu/edit/{id}', 'MenuController@edit');
@ -146,6 +146,11 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro
$router->get('/refferal-code/edit/{id}', 'RefferalCodeController@edit'); $router->get('/refferal-code/edit/{id}', 'RefferalCodeController@edit');
$router->put('/refferal-code/update/{id}', 'RefferalCodeController@update'); $router->put('/refferal-code/update/{id}', 'RefferalCodeController@update');
$router->post('/product-transaction/search', 'ProductTransactionController@search');
$router->post('/product-transaction/add', 'ProductTransactionController@add');
$router->get('/product-transaction/edit/{id}', 'ProductTransactionController@edit');
$router->put('/product-transaction/update/{id}', 'ProductTransactionController@update');
$router->post('/project-role/search', 'ProjectRoleController@search'); $router->post('/project-role/search', 'ProjectRoleController@search');
$router->post('/project-role/add', 'ProjectRoleController@add'); $router->post('/project-role/add', 'ProjectRoleController@add');
$router->get('/project-role/edit/{id}', 'ProjectRoleController@edit'); $router->get('/project-role/edit/{id}', 'ProjectRoleController@edit');

Loading…
Cancel
Save