diff --git a/app/Http/Controllers/CustomersController.php b/app/Http/Controllers/CustomersController.php index ff46be5..0b58fa7 100644 --- a/app/Http/Controllers/CustomersController.php +++ b/app/Http/Controllers/CustomersController.php @@ -151,12 +151,12 @@ class CustomersController extends Controller } public function getOTP(Request $request){ - + $auth_user = Auth::user(); $expired = Carbon::now(); $expired = new Carbon(); $expired = $expired->addHours(24); - $nokp = $request->noic_otp; + $nokp = $request->noic; //pembinaan token function token($length) { @@ -170,39 +170,34 @@ class CustomersController extends Controller shuffle($characters); return implode("", array_slice($characters, 0, $length)); } - $random = token(6); - // dd($expired); - $otp_baru = Http::post(config('url.api') . '/api/otp/generateotp/' . $nokp,[ - 'otptoken' => $random, - 'expired' => $expired, - ]); - // dd($otp_baru); - return redirect()->route('customer_info'); - // $otp_token = Http::get(config('api.url') . '/api/otp/' . $nokp) ->json(); - // // dd($nokp); - // if (is_array($otp_token) || is_object($otp_token)){ - // if($otp_token){ - // return redirect()->route('customer_info'); - // }else{ - // $random = token(6); - - // $otp_baru = Http::post(config('url.api'). '/api/otp/create/' . $nokp,[ - // 'otptoken' => $random, - // 'expired' => $expired - // ]); - - // return redirect()->route('customer_info'); - // } - // }else{ - // $random = token(6); - // $otp_baru = Http::post(config('url.api'). '/api/otp/create/' . $nokp,[ - // 'otptoken' => $random, - // 'expired' => $expired - // ]); + $otp_token = Http::get(config('api.url') . '/api/otp/' . $nokp) ->json(); - // return redirect()->route('customer_info'); - // } + if (is_array($otp_token) || is_object($otp_token)){ + if($otp_token){ + return response(['error' => "OTP Akaun Telah Di Jana"]); + }else{ + $random = token(6); + + $otp_baru = Http::post(config('api.url'). '/api/otp/generateotp/' . $nokp,[ + 'otptoken' => $random, + 'expired' => $expired, + 'kodcaw' => $auth_user['cawangan'] + ]); + + return response()->json(['otp'=>$random]); + } + }else{ + $random = token(6); + + $otp_baru = Http::post(config('api.url'). '/api/otp/generateotp/' . $nokp,[ + 'otptoken' => $random, + 'expired' => $expired, + 'kodcaw' => $auth_user['cawangan'] + ]); + + return response()->json(['otp'=>$random]); + } } } diff --git a/resources/views/customers/info.blade.php b/resources/views/customers/info.blade.php index 94b9ddb..37b76f8 100644 --- a/resources/views/customers/info.blade.php +++ b/resources/views/customers/info.blade.php @@ -124,18 +124,15 @@
-
- @csrf - -
- -
-
+ +
+ +