added function to split for registration of customer
This commit is contained in:
@@ -16,12 +16,8 @@ class TacController extends Controller
|
||||
$tac = tacportal::where([['icno',$request->icno],['tac_no',$request->tac]])->get()->toArray();
|
||||
|
||||
if($tac){
|
||||
$CustomerInfo = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/customers/' . $request->icno)->json();
|
||||
$poskod = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/poskod/' . $CustomerInfo['poskod'])->json();
|
||||
$daerah = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/daerah/' . $poskod['koddaerah'])->json();
|
||||
$negeri =Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/negeri/' . $poskod['kodnegeri'])->json();
|
||||
|
||||
return response(['status' => 1, 'customerinfo' => $CustomerInfo,'namadaerah' => $daerah['namadaerah'],'namanegeri' => $negeri['negeri']]);
|
||||
$DetailsCustomer = $this->getCustomerData($request->icno, true);
|
||||
return response(['status' => 1, 'customerinfo' => $DetailsCustomer['customerinfo'],'namadaerah' => $DetailsCustomer['daerah']['namadaerah'],'namanegeri' => $DetailsCustomer['negeri']['negeri']]);
|
||||
}else{
|
||||
return response(['status' => 0]);
|
||||
}
|
||||
@@ -64,8 +60,8 @@ class TacController extends Controller
|
||||
return response(['message' => true]);
|
||||
}
|
||||
|
||||
$CustomerInfo = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/customers/' . $request->icno)->json();
|
||||
|
||||
$CustomerInfo = $this->getCustomerData($request->icno, false);
|
||||
|
||||
if($CustomerInfo)
|
||||
{
|
||||
$generatestatus = $this->generateTAC($CustomerInfo);
|
||||
@@ -98,7 +94,7 @@ class TacController extends Controller
|
||||
}
|
||||
|
||||
|
||||
$CustomerInfo = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/customers/' . $request->icno)->json();
|
||||
$CustomerInfo = $this->getCustomerData($request->icno, false);
|
||||
|
||||
if($CustomerInfo)
|
||||
{
|
||||
@@ -174,6 +170,33 @@ class TacController extends Controller
|
||||
|
||||
return implode('',$num);
|
||||
}
|
||||
|
||||
private function getCustomerData($icno,$details = false){
|
||||
$CustomerInfo_PKB = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/customers/' . $icno)->json();
|
||||
$CustomerInfo_KOOPKB = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url_koop') .'/api/customers/' . $icno)->json();
|
||||
|
||||
if($CustomerInfo_PKB){
|
||||
if($details == true){
|
||||
$poskod = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/poskod/' . $CustomerInfo_PKB['poskod'])->json();
|
||||
$daerah = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/daerah/' . $poskod['koddaerah'])->json();
|
||||
$negeri =Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/negeri/' . $poskod['kodnegeri'])->json();
|
||||
return ['customerinfo' => $CustomerInfo_PKB,'poskod' => $poskod,'daerah' => $daerah,'negeri' => $negeri];
|
||||
}
|
||||
$CustomerInfo = $CustomerInfo_PKB;
|
||||
}else if($CustomerInfo_KOOPKB){
|
||||
if($details == true){
|
||||
$poskod = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url_koop') . '/api/poskod/' . $CustomerInfo_KOOPKB['poskod'])->json();
|
||||
$daerah = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url_koop') .'/api/daerah/' . $poskod['koddaerah'])->json();
|
||||
$negeri =Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url_koop') .'/api/negeri/' . $poskod['kodnegeri'])->json();
|
||||
return ['customerinfo' => $CustomerInfo_KOOPKB,'poskod' => $poskod,'daerah' => $daerah,'negeri' => $negeri];
|
||||
}
|
||||
$CustomerInfo = $CustomerInfo_KOOPKB;
|
||||
}else{
|
||||
$CustomerInfo = null;
|
||||
}
|
||||
|
||||
return $CustomerInfo;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user