type, [TransactionType::BILL, TransactionType::REFUND])){ $booking = $this->owner->owner; $bank = $this->owner->bank ?? $booking->bank; } else{ $booking = $this->owner; $bank = $this->bank ?? $booking->bank; } //Check if Transaction of type PAYMENT has an override for recipient bank - ends $booking_marking = ''; switch((int) $this->type){ case 1: $request['running_balance'] = $request['running_balance'] + $this->amount; switch ($this->owner_type) { case Booking::class: $booking_marking = $booking->marking; break; case Wallet::class: $booking_marking = Transaction::where('payment_reference', $this->bill_no)->first()->owner->marking; break; } break; case 2: $booking_marking = $booking->marking; $request['running_balance'] = $request['running_balance'] - ($this->amount / $this->currency_rate + $this->service_charge); break; case 5: $request['running_balance'] = $request['running_balance'] - $this->amount; break; case 9: $request['running_balance'] = $request['running_balance'] - $this->amount; break; } return [ 'id' => $this->id, 'booking_marking' => $booking_marking, 'type' => (int) $this->type, 'bill_no' => $this->bill_no, 'payment_reference' => $this->payment_reference, 'payment_method' => (float) $this->payment_method, 'recipient_bank_account' => new BankResource($bank), 'issuer_name' => $this->issuerCompany->name, 'issuer_id' => $this->issuerCompany->id, 'amount' => (double) $this->amount, 'original_amount' => (double) $this->original_amount, 'running_balance' => (double) $current_running_balance, 'currency' => new CurrencyResource($this->currency), 'original_currency' => new CurrencyResource($this->original_currency), 'service_charge' => (double) $this->service_charge, 'tax' => (double) $this->tax, 'currency_rate' => (double) $this->currency_rate, 'status' => (int) $this->status, 'updated_at' => Carbon::parse($this->updated_at)->format('d-m-Y h:i:s A'), 'created_at' => Carbon::parse($this->created_at)->format('d-m-Y h:i:s A') ]; } }