From 501c46d8398921bb13cc20e38298d32c87cbb9a1 Mon Sep 17 00:00:00 2001 From: Amir Date: Wed, 16 Nov 2022 10:09:25 +0800 Subject: [PATCH] Fix export data lelong --- app/Http/Controllers/LelongController.php | 34 ++++++++++++----------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/app/Http/Controllers/LelongController.php b/app/Http/Controllers/LelongController.php index 75e0bb3..0e11365 100644 --- a/app/Http/Controllers/LelongController.php +++ b/app/Http/Controllers/LelongController.php @@ -997,9 +997,8 @@ class LelongController extends Controller foreach ($request->lelongbidmarhun as $data) { $lelmarhun_to_be_inserted = new LelMarhun(); - $lelmarhun_to_be_inserted->kodcaw = $request['kodcaw']; + $lelmarhun_to_be_inserted->kodcaw = $request->kodcaw; $lelmarhun_to_be_inserted->norujukan = $data['norujukan']; - $lelmarhun_to_be_inserted->t_gadai = $data['t_gadai']; $lelmarhun_to_be_inserted->nota = $data['nota']; $lelmarhun_to_be_inserted->batch_no = $newBatchNo; @@ -1008,21 +1007,24 @@ class LelongController extends Controller LelMarhun::on($cawangan['mysql'])->insert($lelmarhun_arr); - $tunai = Tunai::on($cawangan['mysql'])->create([ - 'tarikh' => $request->tarikh, - 'kodlaluan' => "LELONG", - 'masuk' => $request->tunai, - ]); - - $gldetail = GlDetail::on($cawangan['mysql'])->create([ - 'tarikh' => $request->tarikh, - 'dtacct' => "1000/010", - 'ktacct' => "1000/020", - 'teller' => "LELONG ONLINE", - 'descpt' => "SERAHAN LELONG ONLINE", - 'amaun' => $request->gldetail - ]); + if ($request->tunai != null) { + $tunai = Tunai::on($cawangan['mysql'])->create([ + 'tarikh' => $request->tarikh, + 'kodlaluan' => "LELONG", + 'masuk' => $request->tunai, + ]); + } + if ($request->gldetail != null) { + $gldetail = GlDetail::on($cawangan['mysql'])->create([ + 'tarikh' => $request->tarikh, + 'dtacct' => "1000/010", + 'ktacct' => "1000/020", + 'teller' => "LELONG ONLINE", + 'descpt' => "SERAHAN LELONG ONLINE", + 'amaun' => $request->gldetail + ]); + } return response()->json("success"); }