0
public function barcodeDetail(Request $request)
    {
        $return_json = [];
        $receipt = trim($request->get('receipt'));
        $barcode = trim($request->get('barcode'));

        if (empty($receipt)) {

            $NewReceiving = NewReceiving::where('barcode', $request->get('barcode'))->get()->toArray();

            if (0 == sizeof($NewReceiving)) {
                $KTMasterReceipt = new KTMasterReceipt();
                $KTMasterReceipt->FK_CASHIER_CONTROL_ID = 1;
                $KTMasterReceipt->FK_TERMINAL_CONTROL_ID = 1;
                $KTMasterReceipt->save();
                $receipt = $KTMasterReceipt->id;
            }
            else{
                $receipt = $NewReceiving[0]['k_t_master_receipt_id'];
            }

        }

        $KTMasterReceipt = KTMasterReceipt::find($receipt)->KTMaster()->where('barcode', $request->get('barcode'))->get();

        if (0 == sizeof($KTMasterReceipt->toArray())) {
            $decode      = $this->decodeBarcode($barcode);

            $NewReceiving                         = new NewReceiving();
            $NewReceiving->K_T_MASTER_RECEIPT_ID    = $receipt;
            dd($receipt);
            $NewReceiving->LK_REVENUE_CODE_ID       = $receipt;
            $NewReceiving->ACCOUNT_NO               = $receipt;
            $NewReceiving->BILL_REFERENCE           = $receipt;
            $NewReceiving->BILL_AMOUNT              = $receipt;
            $NewReceiving->RECEIPT_NO               = $receipt;
            $NewReceiving->BILL_COUNT               = $receipt;
            $NewReceiving->TYPE                     = $receipt;
            $NewReceiving->save();
        }

        $return_json['receipt'] = $receipt;
        $return_json['KTMasterReceipt'] = KTMasterReceipt::where('id', $receipt)->get();
        $return_json['NewReceiving'] = NewReceiving::where('K_T_MASTER_RECEIPT_ID', $receipt)->get();
        $return_json['PaymentDetail'] = PaymentDetail::where('FK_KT_MASTER_RECEIPT_ID', $receipt)->get();

        return response()->json($return_json);
    }

I have do the code just like above. I have dump the variable and the result is not null or empty. But, when I map the $receipt value to any column it return ' Creating default object from empty value'.

tereško
  • 58,060
  • 25
  • 98
  • 150
  • Narrow down which line is reporting the error. – Devon Bessemer Jul 08 '18 at 22:31
  • You get this error when you try to assign to an object without initializing it beforehand... It is complaining that $NewReceiving is empty, not $receipt. I don't understand why your constructor would not return an object? Something fishy with this... – Serge Jul 09 '18 at 00:22
  • This might help you with. https://stackoverflow.com/questions/8900701/creating-default-object-from-empty-value-in-php?answertab=votes#tab-top – markantonay Jul 09 '18 at 01:29
  • ah thanks you to guys. i just misspelled the variable name. i have used different variable name earlier. (^_^)'.. i just noticed it from @Serge comment – Ahmad Alif Jul 10 '18 at 12:02

0 Answers0