json(Customer::on('mysql2')->get()); } public function showOneCustomer($id) { return response()->json(Customer::on('mysql2')->find($id)); } public function showOneCustomerByIC($ic){ $cawangan_all = Cawangan::on('mysql7')->get(); $customer_all = []; foreach($cawangan_all as $index=>$cawangan){ $customer = Customer::on($cawangan['mysql']) ->where('kplama','=',$ic) ->orWhere('kpbaru','=',$ic) ->first(); if($customer != null){ array_push($customer_all,$customer); } } return response()->json($customer_all); } public function showOneCustomerGadai($ic,$status){ if($status == 'belum_tebus'){ $gadai_status = ''; }elseif($status == 'sudah_tebus'){ $gadai_status = 'T'; }elseif($status == 'lelong'){ $gadai_status = 'L'; } $cawangan_all = Cawangan::on('mysql7')->get(); $gadai_all = []; foreach($cawangan_all as $index=>$cawangan){ if($status == 'belum_tebus' || $status == 'sudah_tebus'){ $gadai = Gadai::on($cawangan['mysql']) ->where([['sttebus','=',$gadai_status],['nokp','=',$ic]]) ->get(); if(sizeof($gadai) != 0){ array_push($gadai_all,$gadai); } }elseif($status == 'lelong'){ $gadai = Gadai::on($cawangan['mysql']) ->where([['sttebus','=',$gadai_status],['nokp','=',$ic]]) ->rightJoin('lelong', 'gadai.norujukan', '=', 'lelong.norujukan') ->get(); if(sizeof($gadai) != 0){ array_push($gadai_all,$gadai); } } } return response()->json($gadai_all); } public function create(Request $request) { $this->validate($request, [ ]); $customer = Customer::create($request->all()); return response()->json($customer, 201); } public function update($id, Request $request) { $customer = Customer::findOrFail($id); $customer->update($request->all()); return response()->json($customer, 200); } public function delete($id) { Customer::findOrFail($id)->delete(); return response('Deleted Successfully', 200); } }