Merge branch 'master' of https://gitlab.com/online-sistem1/api_arrahn into apiaku
This commit is contained in:
@@ -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 = [];
|
||||
|
||||
Reference in New Issue
Block a user