}
    if ($invalidSender) {
        $error['senderError'][] = 'Invalid Character selected to transfer funds from.';
    }
    if ($senderCharacter->name == $recipient) {
        $error['recipientError'][] = 'You cannot transfer funds to yourself.';
    }
    $recipientCharacter = Character::where('name', $recipient)->first();
    if (!$recipientCharacter) {
        $error['recipientError'][] = 'Recipient character does not exist.';
    }
    $senderBalance = Balance::where('character_id', $senderCharacter->id)->first();
    $recipientBalance = Balance::where('character_id', $recipientCharacter->id)->first();
    if (!$senderBalance) {
        $error['senderError'][] = 'No balance found for sender, ensure one exists.';
    }
    if (!$recipientBalance) {
        $error['recipientError'][] = 'Recipient does not have a balance,
                                  they must have a balance before receiving a transaction.';
    }
    if (!empty($error)) {
        return $this->view->render($response, 'transaction-create.php', ['senderError' => $error['senderError'], 'recipientError' => $error['recipientError'], 'amountError' => $error['amountError'], 'characters' => $characters]);
    }
    $transaction = new Transaction();
    $transactionCompleted = $transaction->performTransaction($amount, $senderCharacter->id, $recipientCharacter->id);
    if ($transactionCompleted) {
        Transaction::create(['sender_character_id' => $senderCharacter->id, 'recipient_character_id' => $recipientCharacter->id, 'amount' => $amount]);
        Audit::create(['category' => 'Successful Transaction', 'log_note' => 'Transaction successfully completed for the amount of ' . $amount . ' between ' . $senderCharacter->name . ' and ' . $recipientCharacter->name, 'user_id' => $user->id, 'ip_address' => $_SERVER['REMOTE_ADDR']]);
    }
    return $this->view->render($response, 'transaction-create.php', ['success' => 'Credits transferred successfully.', 'characters' => $characters]);
});