jhutto
198
1
General

Calling Functions inside same controller

Posted 6 months ago by jhutto

I'm working on a project which process credit cards. I have the separate credit card functions inside a controller and they work individually. They are post functions returning data and then a view.

But I need to setup a way to call them individually within the controller because I need to process an if case statement and return the $order data that is processed by the individual function and return the order information to the view.

I could make one very large function that processes a long if then else, but the function would get extremely long and hard to read. Any Help? Thanks.

public function process(Request $request)
{
    if ($request->paymenttype = 1) {
    process this credit card method function()  and return order information ($order)     
    $Order = Order::find($OrderID);

    }

    if ($request->paymenttype = 1) {
    process this credit card method function()  and return order information ($order)
    $Order = Order::find($OrderID);
    }


    if ($request->paymenttype = 1) {
    process this credit card method function()  and return order information ($order)   
    $Order = Order::find($OrderID);
    }

        

    return view('checkout.complete', compact('order'));
}

Please sign in or create an account to participate in this conversation.