Fix create and edit gadaian api: set null value if value passed is null

This commit is contained in:
amirhassan
2024-02-14 13:58:20 +08:00
parent 046a575cdb
commit c327de1997
+4 -4
View File
@@ -91,9 +91,9 @@ class MarhunController extends Controller
'n_marhun' => $nilai_marhun
];
// Remove keys berat_batu_permata if value is null
// Set value berat_batu_permata to null if value passed is null
if($marhunToCreate['berat_batu_permata'] == '') {
unset($marhunToCreate['berat_batu_permata']);
$marhunToCreate['berat_batu_permata'] = null;
};
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
@@ -175,9 +175,9 @@ class MarhunController extends Controller
'n_marhun' => $nilai_marhun
];
// Remove keys berat_batu_permata if value is null
// Set value berat_batu_permata to null if value passed is null
if($marhunToUpdate['berat_batu_permata'] == '') {
unset($marhunToUpdate['berat_batu_permata']);
$marhunToUpdate['berat_batu_permata'] = null;
};
$jemas = Marhun::on($cawangan['mysql'])->where([['recno','=',$request->recno],['norujukan','=',$norujukan]])->update($marhunToUpdate);