api for customer online update
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Customer;
|
||||
use App\Gadai;
|
||||
use App\Lelong;
|
||||
use App\Cawangan;
|
||||
use App\Poskod;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CustomerController extends Controller
|
||||
@@ -114,6 +115,32 @@ class CustomerController extends Controller
|
||||
return response()->json($customer, 200);
|
||||
}
|
||||
|
||||
public function updateOnline($nokp,Request $request){
|
||||
$cawangan_all = Cawangan::on('mysql7')->get();
|
||||
foreach($cawangan_all as $index=>$cawangan){
|
||||
$customer = Customer::on($cawangan['mysql'])
|
||||
->where('kplama','=',$nokp)
|
||||
->orWhere('kpbaru','=',$nokp)
|
||||
->first();
|
||||
if($customer != null){
|
||||
$poskod = Poskod::on('mysql7')->where('poskod','=',$request->poskod)->first();
|
||||
$customer_update = Customer::on($cawangan['mysql'])
|
||||
->where('kplama','=',$nokp)
|
||||
->orWhere('kpbaru','=',$nokp)
|
||||
->update(array(
|
||||
'alamat1' => $request->alamat,
|
||||
'poskod' => $request->poskod,
|
||||
'koddaerah' => $poskod['koddaerah'],
|
||||
'kodnegeri' => $poskod['kodnegeri'],
|
||||
'telefon' => $request->telefon1,
|
||||
'telefon2' => $request->telefon2
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return response()->json($customer_update, 200);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
Customer::findOrFail($id)->delete();
|
||||
|
||||
@@ -31,9 +31,14 @@ class MarhunController extends Controller
|
||||
return response()->json($marhun_all);
|
||||
}
|
||||
|
||||
public function getAllJemas($kodcaw){
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$jemas = Jemas::on($cawangan['mysql'])->get();
|
||||
public function getMarhunName (Request $request){
|
||||
$jemas = Jemas::on('mysql7')->where('marhun','=',$request->marhun)->first();
|
||||
|
||||
return response()->json($jemas);
|
||||
}
|
||||
|
||||
public function getAllJemas(){
|
||||
$jemas = Jemas::on('mysql7')->get();
|
||||
|
||||
return response()->json($jemas);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user