'PHP DRY Principle if.. statement

I am still learning and have been reading on DRY Principles for a while now, was told by my mentor that I need to adhere to the DRY principle for this code below:

public function showResult(Request $request) 
{

    if ($request->tac_no !== $request->otp && $request->statusChanged=="true") {
        return view(
            '/maybank/result', [
            'fpx_creditAuthNo'=>'',
            'fpx_msgToken'=>$request->fpx_msgToken,
            'fpx_txnCurrency'=>$request->fpx_txnCurrency,
            'fpx_sellerOrderNo'=>$request->fpx_sellerOrderNo,
            'fpx_creditAuthCode'=>'',
            'fpx_fpxTxnTime'=>$request->fpx_fpxTxnTime,
            'fpx_makerName'=>'',
            'fpx_debitAuthNo'=>'0000000000',
            'fpx_txnAmount'=>$request->fpx_txnAmount,
            'fpx_sellerExId'=>$request->fpx_sellerExId,
            'fpx_buyerBankId'=>$request->fpx_buyerBankId,
            'fpx_msgType'=>$request->fpx_msgType,
            'fpx_checkSum'=>$request->fpx_checkSum,
            'fpx_sellerExOrderNo'=>$request->fpx_sellerExOrderNo,
            'fpx_buyerName'=>'TRANSACTION FAILED',
            'fpx_sellerTxnTime'=>$request->fpx_sellerTxnTime,
            'fpx_sellerId'=>$request->fpx_sellerId,
            'fpx_buyerIban'=>$request->fpx_buyerIban,
            'fpx_debitAuthCode'=> $request->fpx_debitAuthCode,
            'fpx_buyerId'=>$request->fpx_buyerId,
            'fpx_buyerBankBranch'=>$request->fpx_buyerBankBranch,
            'fpx_fpxTxnId'=>$request->fpx_fpxTxnId]
        );
    }

    return view(
        '/maybank/result', [
            'fpx_creditAuthNo'=>$request->fpx_creditAuthNo,
            'fpx_msgToken'=>$request->fpx_msgToken,
            'fpx_txnCurrency'=>$request->fpx_txnCurrency,
            'fpx_sellerOrderNo'=>$request->fpx_sellerOrderNo,
            'fpx_creditAuthCode'=>$request->fpx_creditAuthCode,
            'fpx_fpxTxnTime'=>$request->fpx_fpxTxnTime,
            'fpx_makerName'=>$request->fpx_makerName,
            'fpx_debitAuthNo'=>$request->fpx_debitAuthNo,
            'fpx_txnAmount'=>$request->fpx_txnAmount,
            'fpx_sellerExId'=>$request->fpx_sellerExId,
            'fpx_buyerBankId'=>$request->fpx_buyerBankId,
            'fpx_msgType'=>$request->fpx_msgType,
            'fpx_checkSum'=>$request->fpx_checkSum,
            'fpx_sellerExOrderNo'=>$request->fpx_sellerExOrderNo,
            'fpx_buyerName'=> $request->fpx_buyerName,
            'fpx_sellerTxnTime'=>$request->fpx_sellerTxnTime,
            'fpx_sellerId'=>$request->fpx_sellerId,
            'fpx_buyerIban'=>$request->fpx_buyerIban,
            'fpx_debitAuthCode'=>$request->fpx_debitAuthCode,
            'fpx_buyerId'=>$request->fpx_buyerId,
            'fpx_buyerBankBranch'=>$request->fpx_buyerBankBranch,
        'fpx_fpxTxnId'=>$request->fpx_fpxTxnId]
    );
}

I was thinking of wrapping the same parameters in an array and call them in a function, but I cant seem get how to actually do it. I am still learning, hope anyone can help. Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source