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;
|
$nilai_marhun = $request_data->berat_emas * $hargaemas;
|
||||||
|
|
||||||
|
$marhunToCreate = [
|
||||||
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
|
|
||||||
$marhun = Marhun::on($cawangan['mysql'])->create([
|
|
||||||
'kodcaw'=> $kodcaw,
|
'kodcaw'=> $kodcaw,
|
||||||
'norujukan'=> $request_data->norujukan,
|
'norujukan'=> $request_data->norujukan,
|
||||||
't_gadai' => $current->toDateString(),
|
't_gadai' => $current->toDateString(),
|
||||||
@@ -91,7 +89,15 @@ class MarhunController extends Controller
|
|||||||
'berat' => $request_data->berat_emas,
|
'berat' => $request_data->berat_emas,
|
||||||
'harga' => $hargaemas,
|
'harga' => $hargaemas,
|
||||||
'n_marhun' => $nilai_marhun
|
'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 = new Audit();
|
||||||
$audit->users = $request_data->teller;
|
$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();
|
$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(
|
$marhunToUpdate = [
|
||||||
[
|
'karat' => $request->karat,
|
||||||
'karat' => $request->karat,
|
'marhun' => $request->marhun,
|
||||||
'marhun' => $request->marhun,
|
'nota' => $request->nota,
|
||||||
'nota' => $request->nota,
|
'batu_permata' => $request->batu_permata,
|
||||||
'batu_permata' => $request->batu_permata,
|
'berat_batu_permata' => $request->berat_batu_permata,
|
||||||
'berat_batu_permata' => $request->berat_batu_permata,
|
'berat' => $request->berat,
|
||||||
'berat' => $request->berat,
|
'harga' => $harga['harga'],
|
||||||
'harga' => $harga['harga'],
|
'n_marhun' => $nilai_marhun
|
||||||
'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();
|
$new_data = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->first();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user