FaiChan
7 months ago

How to return redirect to pervious form post in controller?

Posted 7 months ago by FaiChan

Version: Laravel 5.4.16

When submitting a form with the POST method to the OrderController method,

I would like to return back to the previous form page and with display the message alert.

But it returns "MethodNotAllowedHttpException in RouteCollection.php line 233:" error message.

please help.. thanks so much.

Route/web.php

 Route::post('order_update','[email protected]' )->name('order_update');

Controller

$order_id= $request->id;

if ( $id->status === 'processing') {

                 // update database table
    }
   else
   {
      return back()->with('fail','the order status is locked');
    }

View

  @if ($message = Session::get('fail'))
        <div class="alert alert-success alert-block">
            <button type="button" class="close" data-dismiss="alert">×</button>
            <strong>{{ $message }}</strong>
        </div>
    @endif

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