This commit is contained in:
MUHD HAFIFIE
2021-08-12 23:42:34 +08:00
2 changed files with 101 additions and 0 deletions
@@ -63,6 +63,23 @@ class CustomerController extends Controller
return response()->json($customer);
}
public function showOneCustomerByICAdmin(Request $request){
// $cawangan_all = Cawangan::on('mysql7')->get();
// $customer_all = [];
// foreach($cawangan_all as $index=>$cawangan){
$customer = Customer::on('mysql7')
->where('kplama','=',$request->ic)
->orWhere('kpbaru','=',$request->ic)
->first();
// if($customer != null){
// array_push($customer_all,$customer);
// }
// }
return response()->json($customer);
}
public function showOneCustomerByICMobile($ic){
$cawangan_all = Cawangan::on('mysql7')->get();
@@ -428,6 +445,88 @@ class CustomerController extends Controller
return response()->json($customer_update, 200);
}
public function customerUpdateAdmin(Request $request){
$poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first();
if($request->ic_asal != $request->icno){
$existing_customer = Customer::on('mysql7')
->where('kplama','=',$request->icno)
->orWhere('kpbaru','=',$request->icno)
->get();
if($existing_customer->isEmpty()){
$cawangan_all = Cawangan::on('mysql7')->get();
foreach($cawangan_all as $index=> $cawangan){
$gadai = Gadai::on($cawangan['mysql'])->where('nokp',$request->ic_asal)->update([
'nokp'=>$request->icno
]);
}
$data_asal = $customer_update = Customer::on('mysql7')
->where('kplama','=',$request->ic_asal)
->orWhere('kpbaru','=',$request->ic_asal)
->first();
if($data_asal['kpbaru'] != null){
$customer_update = Customer::on('mysql7')
->where('kplama','=',$request->ic_asal)
->orWhere('kpbaru','=',$request->ic_asal)
->update(array(
'kpbaru' => $request->icno,
'telefon' => $request->telefon1,
'telefon2' => $request->telefon2,
'kodbank' => $request->kodbank,
'noakaun' => $request->noakaun,
'nota' => $request->nota,
'nama' => $request->nama,
'alamat1' => $request->alamat,
'poskod' => $request->poskod,
'koddaerah' => $poskod['koddaerah'],
'kodnegeri' => $poskod['kodnegeri']
));
}else{
$customer_update = Customer::on('mysql7')
->where('kplama','=',$request->ic_asal)
->orWhere('kpbaru','=',$request->ic_asal)
->update(array(
'kplama' => $request->icno,
'telefon' => $request->telefon1,
'telefon2' => $request->telefon2,
'kodbank' => $request->kodbank,
'noakaun' => $request->noakaun,
'nota' => $request->nota,
'nama' => $request->nama,
'alamat1' => $request->alamat,
'poskod' => $request->poskod,
'koddaerah' => $poskod['koddaerah'],
'kodnegeri' => $poskod['kodnegeri']
));
}
}else{
return response()->json('existing');
}
}else if($request->ic_asal == $request->icno){
$customer_update = Customer::on('mysql7')
->where('kplama','=',$request->icno)
->orWhere('kpbaru','=',$request->icno)
->update(array(
'telefon' => $request->telefon1,
'telefon2' => $request->telefon2,
'kodbank' => $request->kodbank,
'noakaun' => $request->noakaun,
'nota' => $request->nota,
'nama' => $request->nama,
'alamat1' => $request->alamat,
'poskod' => $request->poskod,
'koddaerah' => $poskod['koddaerah'],
'kodnegeri' => $poskod['kodnegeri']
));
}
return response()->json($customer_update, 200);
}
public function listNorujukanMobile($nokp){
$cawangan_all = Cawangan::on('mysql7')->get();
$array_norujukan = [];