type){ case 5: $description = (double) $this->amount.' Credit Top up'; $request['running_balance'] = bcsub($request['running_balance'], $this->amount, 5); break; case 9: $description = 'Credit Voucher for '.$this->payment_reference; $request['running_balance'] = bcsub($request['running_balance'], $this->amount, 5); break; case 1: $booking = Transaction::where('payment_reference', $this->bill_no)->first()->owner; if(!$booking) { $description = 'Payment for unknown booking, please contact tech support.'; break; } $request['running_balance'] = bcadd($request['running_balance'], $this->amount, 5); $marking = $booking->marking; $description = 'Payment For booking refs.'.''.$marking.''; break; case 11: $description = 'Debit Voucher for '.$this->payment_reference; $request['running_balance'] = bcadd($request['running_balance'], $this->amount, 5); break; } return [ 'id' => (int) $this->id, 'type' => (int) $this->type, 'marking' => $this->owner->owner->reference, 'bill_no' => $this->bill_no, 'reference' => $this->payment_reference, 'payment_method' => (float) $this->payment_method, 'issuer_name' => $this->issuerCompany->name, 'amount' => (double) $this->amount, 'running_balance' => (double) $current_running_balance, 'service_charge' => (double) $this->service_charge, 'tax' => (double) $this->tax, 'status' => (int) $this->status, 'description' => $description, 'details' => TransactionDetailResource::collection($this->transactionDetails), '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') ]; } }