From cc8b2cf1f7bb61a91faa30e914d7e696cb77a597 Mon Sep 17 00:00:00 2001 From: wahyun Date: Tue, 6 Feb 2024 12:52:39 +0700 Subject: [PATCH 1/3] update method sendEmail --- app/Http/Controllers/AuthController.php | 31 ++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 53d34f4..4f06657 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -113,18 +113,33 @@ class AuthController extends Controller public function sendEmail(Request $request) { - $hashed = Str::random(15); + if (empty($request->password)) { + $hashed = Str::random(15); + } else { + $hashed = $request->password; + } + $email = $request->email; $user = User::select('email', 'name', 'username')->where('email', $email)->first(); if (!$user || empty($email)) { - return response()->json(['status' => 'error', 'message' => 'e-mail not found '], 400); + return response()->json(['status' => 'error', 'message' => 'e-mail not found'], 400); } else { - $this->reqHttpCurl($email, $hashed, $user->username, $user->name); - if (User::where('email', $email)->update(['password' => md5($hashed)])) - return response()->json(['status' => 'success', 'code' => 200, 'message' => 'Password already sent to mail'], 200); - - return response()->json(['status' => 'error', 'code' => 400, 'message' => 'e-mail not found '], 400); + if($request->username) { + $username = $request->username; + $name = $request->username; + } else { + $username = $user->username; + $name = $user->name; + } + $this->reqHttpCurl($email, $hashed, $username, $name); + if(empty($request->password)) { + if (User::where('email', $email)->update(['password' => md5($hashed)])) { + return response()->json(['status' => 'success', 'code' => 200, 'message' => 'Password already sent to mail'], 200); + } + } else { + return response()->json(['status' => 'success', 'code' => 200, 'message' => 'Password already sent to mail'], 200); + } } } @@ -132,7 +147,7 @@ class AuthController extends Controller { $postData = [ "to" => $email, - "username" => $name, + "name" => $name, "username" => $username, "password" => $password, "from" => "app.integrasia@integrasiautama.com", From 90e51a829d83ef7419133785352086a5fab773ce Mon Sep 17 00:00:00 2001 From: wahyun Date: Tue, 6 Feb 2024 12:53:07 +0700 Subject: [PATCH 2/3] product transaction --- .../ProductTransactionController.php | 30 +++++++++++++++++++ app/Models/ProductTransaction.php | 25 ++++++++++++++++ routes/web.php | 1 + 3 files changed, 56 insertions(+) create mode 100644 app/Http/Controllers/ProductTransactionController.php create mode 100644 app/Models/ProductTransaction.php diff --git a/app/Http/Controllers/ProductTransactionController.php b/app/Http/Controllers/ProductTransactionController.php new file mode 100644 index 0000000..c5d7a12 --- /dev/null +++ b/app/Http/Controllers/ProductTransactionController.php @@ -0,0 +1,30 @@ +validate($request, [ + 'company_id' => 'required|integer', + 'type_paket' => 'required|string', + 'amount' => 'required', + 'exp_ospro' => 'required' + ]); + + $data = $request->all(); + + $data['created_by'] = $this->currentName; + $result = ProductTransaction::create($data); + + 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); + } + } +} diff --git a/app/Models/ProductTransaction.php b/app/Models/ProductTransaction.php new file mode 100644 index 0000000..c4a59e5 --- /dev/null +++ b/app/Models/ProductTransaction.php @@ -0,0 +1,25 @@ +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('/company-management-user/search', 'CompanyController@search'); $router->post('/human-resource-user/add', 'HumanResourceController@add_user'); $router->get('/company-management-user/edit/{id}', 'CompanyController@edit'); From e06111927d7d734daf95f8667b757d43c10e8b79 Mon Sep 17 00:00:00 2001 From: wahyun Date: Tue, 6 Feb 2024 12:53:31 +0700 Subject: [PATCH 3/3] add type_account fillable --- app/Models/Company.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Models/Company.php b/app/Models/Company.php index 403c27d..85e5868 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -33,6 +33,7 @@ class Company extends Model 'updated_at', 'updated_by', 'cluster', + 'type_account', 'date_register' ]; }