Update create and edit gadain feat validation for batu permata: discard key if value is null
This commit is contained in:
@@ -76,9 +76,7 @@ class MarhunController extends Controller
|
||||
|
||||
$nilai_marhun = $request_data->berat_emas * $hargaemas;
|
||||
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$marhun = Marhun::on($cawangan['mysql'])->create([
|
||||
$marhunToCreate = [
|
||||
'kodcaw'=> $kodcaw,
|
||||
'norujukan'=> $request_data->norujukan,
|
||||
't_gadai' => $current->toDateString(),
|
||||
@@ -91,7 +89,15 @@ class MarhunController extends Controller
|
||||
'berat' => $request_data->berat_emas,
|
||||
'harga' => $hargaemas,
|
||||
'n_marhun' => $nilai_marhun
|
||||
]);
|
||||
];
|
||||
|
||||
// Remove keys berat_batu_permata if value is null
|
||||
if($marhunToCreate['berat_batu_permata'] == '') {
|
||||
unset($marhunToCreate['berat_batu_permata']);
|
||||
};
|
||||
|
||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
||||
$marhun = Marhun::on($cawangan['mysql'])->create($marhunToCreate);
|
||||
|
||||
$audit = new Audit();
|
||||
$audit->users = $request_data->teller;
|
||||
@@ -158,17 +164,23 @@ class MarhunController extends Controller
|
||||
|
||||
$old_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->first();
|
||||
|
||||
$jemas = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->update(
|
||||
[
|
||||
'karat' => $request->karat,
|
||||
'marhun' => $request->marhun,
|
||||
'nota' => $request->nota,
|
||||
'batu_permata' => $request->batu_permata,
|
||||
'berat_batu_permata' => $request->berat_batu_permata,
|
||||
'berat' => $request->berat,
|
||||
'harga' => $harga['harga'],
|
||||
'n_marhun' => $nilai_marhun
|
||||
]);
|
||||
$marhunToUpdate = [
|
||||
'karat' => $request->karat,
|
||||
'marhun' => $request->marhun,
|
||||
'nota' => $request->nota,
|
||||
'batu_permata' => $request->batu_permata,
|
||||
'berat_batu_permata' => $request->berat_batu_permata,
|
||||
'berat' => $request->berat,
|
||||
'harga' => $harga['harga'],
|
||||
'n_marhun' => $nilai_marhun
|
||||
];
|
||||
|
||||
// Remove keys berat_batu_permata if value is null
|
||||
if($marhunToUpdate['berat_batu_permata'] == '') {
|
||||
unset($marhunToUpdate['berat_batu_permata']);
|
||||
};
|
||||
|
||||
$jemas = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->update($marhunToUpdate);
|
||||
|
||||
$new_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->first();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user