kodcaw
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user