mardi 1 novembre 2016

Laravel 5 how to return to a POST request with validation errors

I have a POST route in Laravel:

Route::post('/quote-summary', 'QuoteController@quoteSummary')->name('quote-summary');

On the view for this route I have a form that submits to another route:

Route::post('/proceed-to-payment', 'QuoteController@proceedToPayment')->name('proceed-to-payment');

Here is my controller method for proceed-to-payment:

public function proceedToPayment(Request $request) {

    if(empty($request->get('tick_statement_of_fact'))) {
        return redirect()->route('quote-summary')->with('tick_statement_of_fact', 'I am so frustrated.');


    } else {
        return view('quote.payment', compact('date_cover_required', 'expiry_date'));
    }

}

I am trying to redirect back to quote-summary but as it was a POST I am getting a MethodNotAllowedHttpException as the redirect seems to be doing a GET.

Any ideas on how I can return to my POST route with some validation error messages?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2f84DFq
via IFTTT

Aucun commentaire:

Enregistrer un commentaire