diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 4380b15..e320f72 100644 --- a/app/Http/Controllers/Controller.php +++ b/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); } } - $resultMove = $dokumen->move($folderPath, $name); + $resultMove = $dokumen->move($initPath, $name); return [ 'resultMove' => $resultMove diff --git a/app/Http/Controllers/HumanResourceController.php b/app/Http/Controllers/HumanResourceController.php index acffb77..a29c92f 100644 --- a/app/Http/Controllers/HumanResourceController.php +++ b/app/Http/Controllers/HumanResourceController.php @@ -119,11 +119,11 @@ class HumanResourceController extends Controller if(empty($humanresource)) { return response()->json(['status' => 'failed', 'message' => 'Data Human Resource not found!', 'code' => 400], 400); } - $transaction = ProductTransaction::query() - ->where('company_id', $request->company_id); - $cloneQueryTransaction = clone $transaction; - if($request->company_id && isset($request->password) && isset($request->username)) : + if($request->company_id && isset($request->password) && isset($request->username)) { + $transaction = ProductTransaction::query() + ->where('company_id', $request->company_id); + $cloneQueryTransaction = clone $transaction; $countCreate = false; $projectResult = HumanResource::query() ->selectRaw('count(*) as total_hr') @@ -144,7 +144,9 @@ class HumanResourceController extends Controller } else { $countCreate = true; } - endif; + } else { + $countCreate = true; + } $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->password ? $this->validate($request,['password'=>'required|min:8']) : ''; @@ -166,7 +168,7 @@ class HumanResourceController extends Controller } 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 { return response()->json(['status' => 'failed', 'message' => 'Human Resource Pool failed updated!', 'code' => 400], 400); } diff --git a/app/Http/Controllers/ProductTransactionController.php b/app/Http/Controllers/ProductTransactionController.php index 9ee9836..07fbb68 100644 --- a/app/Http/Controllers/ProductTransactionController.php +++ b/app/Http/Controllers/ProductTransactionController.php @@ -24,14 +24,14 @@ class ProductTransactionController extends Controller if ($result) { return response()->json(['status' => 'success', 'data' => $result, 'message' => 'Add Transaction successfully!', 'code' => 200], 200); } 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) { 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(); } @@ -40,50 +40,30 @@ class ProductTransactionController extends Controller if ($result) { return response()->json(['status' => 'success', 'code' => 200, 'data' => $result], 200); } 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) { - if (!$id || (int) $id < 0 || $id == "") { - return response()->json(['status' => 'failed', 'message' => 'id is required!', 'code' => 400], 400); + if(!$id || (int) $id < 0 || $id==""){ + return response()->json(['status'=>'failed','message'=>'Id is required!','code'=>400], 400); } $data = ProductTransaction::find($id); - - if ($data) { + if($data){ $result = $data->update($request->all()); - } else { - return response()->json(['status' => 'failed', 'message' => 'data Transaction not found!', 'code' => 400], 400); + }else{ + return response()->json(['status'=>'failed','message'=>'Data transaction not found!','code'=>400], 400); die(); } - if ($result) { - 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 { - return response()->json(['status' => 'failed', 'message' => 'data Transaction failed deleted!', 'code' => 400], 400); + if($result){ + 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); } } diff --git a/app/Http/Controllers/RefferalCodeController.php b/app/Http/Controllers/RefferalCodeController.php index 65a3e3b..1e89fb4 100644 --- a/app/Http/Controllers/RefferalCodeController.php +++ b/app/Http/Controllers/RefferalCodeController.php @@ -23,7 +23,7 @@ class RefferalCodeController extends Controller $result = RefferalCode::create($data); 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{ return response()->json(['status'=>'failed','message'=>'Add refferal Code failed!','code'=>400], 400); } diff --git a/app/Models/HumanResource.php b/app/Models/HumanResource.php index 0e4731a..e1b3706 100644 --- a/app/Models/HumanResource.php +++ b/app/Models/HumanResource.php @@ -14,6 +14,7 @@ class HumanResource extends Model protected $fillable = [ 'role_id', 'username', + 'discount_id', 'password', 'session_login', 'name', diff --git a/app/Models/RefferalCode.php b/app/Models/RefferalCode.php index 8046efc..c6a61fc 100644 --- a/app/Models/RefferalCode.php +++ b/app/Models/RefferalCode.php @@ -12,7 +12,6 @@ class RefferalCode extends Model const UPDATED_AT = 'updated_at'; protected $fillable = [ - 'id', 'code', 'amount', 'exp', diff --git a/routes/web.php b/routes/web.php index 76955c6..ed2e751 100644 --- a/routes/web.php +++ b/routes/web.php @@ -9,7 +9,7 @@ $router->group(['prefix' => 'api', 'middleware' => 'cors'], function () use ($ro // Landing Route $router->post('/send-email', 'AuthController@sendEmail'); $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('/human-resource-user/add', 'HumanResourceController@add_user'); $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('/menu-company-user/add-multiple', 'MenuCompanyController@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->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->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/add', 'ProjectRoleController@add'); $router->get('/project-role/edit/{id}', 'ProjectRoleController@edit');