bimoan
bimoan

Reputation: 189

MethodNotAllowedHttpException on form submit

I have some problem with my form::open with laravel 5.5 i am getting error

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No message

This is my addressescontroller

public function store(Request $request)
{
    $this->validate($request,[
        'addressline'=>'required',
        'city'=>'required',
        'state'=>'required',
        'zip'=>'required|integer',
        'phone'=>'required|integer',
    ]);

    Auth::user()->address()->create($request->all());

    return redirect()->route('checkout.payment');
}

this is my route

Route::get('payment','CheckoutController@payment')->name('checkout.payment');

. this is my shiping-info.blade.php

   @extends('layouts.main')

@section('content')
    <br>
<div class="row">
    <div class="small-6 small-centered columns">
        <h3>Shipping Info</h3>

        {!! Form::open(array('action' => 'checkout.payment', 'method' => 'POST')) !!}


   .....

 {{ Form::submit('Proceed to Payment', array('class' => 'button success')) }}
    {!! Form::close() !!}

when i submit the button code.. the error like above .. whats wrong ?

Upvotes: 1

Views: 621

Answers (2)

Md. Miraj Khan
Md. Miraj Khan

Reputation: 377

Use

Route::post('payment','CheckoutController@payment')->name('checkout.payment');

insted of

Route::get('payment','CheckoutController@payment')->name('checkout.payment');

Upvotes: 0

Binit Ghetiya
Binit Ghetiya

Reputation: 1979

In your route there is GET method defined

Route::get('payment','CheckoutController@payment')->name('checkout.payment');

But you are posting as POST method.

So please change

Route::post('payment','CheckoutController@payment')->name('checkout.payment');

Then it will work.

Upvotes: 3

Related Questions