logic($transactionsArray); } public function getallivoiceid1( $transactionsArray) { // dd(json_decode($transactionsArray)); $transactions = Transaction::whereIn('id', json_decode($transactionsArray))->where('type', TransactionType::SHIPPING_INVOICE)->get(); $total = $transactions->sum('amount'); $packingList =$transactions[1]->owner; $order = $packingList->owner; $companyModule = $order->companyModule; $company = $companyModule->company; $wallet = $company->wallets()->first(); if (!$wallet) { $object = new WalletObject($company->id, 1, $this->generatesWalletCode->execute()); /** @var Wallet $wallet */ $wallet = $this->createsWallet->execute($object, $company); } $billNumber = (App()->make(GeneratesTransactionBillNumber::class))->execute('TOPUP-'); if($total < 0) { throw new MalformedRequestException('Top up credit value must be greater than zero.'); } $billPlzBill = (App()->make(CreatesBillplzBill::class))->execute($company->name, 'example@gmail.com', 'This payment is credit topup for company ref. ' . $company->reference, $total, $billNumber, 'bank code', true); $transaction_object = new TransactionObject($billNumber, TransactionType::TOP_UP, 1, $company->id, 1, PaymentMethodType::PAYMENT_GATEWAY, $total, $total, 1, 1, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, [], 'test'); // $transaction = $this->createsTransaction->execute($wallet, $transaction_object); $transaction = (App()->make(CreatesTransaction::class))->execute($wallet, $transaction_object); $result= (App()->make(UpdatesWalletBalance::class))->execute($wallet, $total); foreach ($transactions as $key => $value) { multipleInvoicesWithOnePayment::create([ 'topUp_request_id' => $transaction->id, 'transaction_id' => $value->id ]); } dd($transaction->id); } }