Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
435 views
in Technique[技术] by (71.8m points)

laravel - How to solve this error, The GET method is not supported for this route. Supported methods: POST

I'm having a problem with this? How to solve this error: The GET method is not supported for this route. Supported methods: POST.

<form method="POST" action="{{ route('term-one.store')}}">
    @csrf
    <div class="row">
        <div class="col-md-12">
            <input type="text" id="name" name="name" class="form-control @error('name') is-invalid @enderror"
                   value="{{ old('name') }}">
            <input type="hidden" name="grade" value="{{$grade->id}}"/>
            <input type="hidden" name="subject" value="{{$subject->id}}"/>
            @error('name')
            <span class="invalid-feedback" role="alert">
                <strong>{{ $message }}</strong>
            </span>
            @enderror
        </div>
    </div>
    <div class="row text-right">
        <div class="col-md-12 mt-2">
            <button type="submit" class="btn btn-primary">Create</button>
        </div>
    </div>
</form>

Controller

public function store(Request $request)
{
    $this->validate($request,[
        'name' => 'required|min:3|max:150',
        'grade' =>'required',
        'subject' => 'required'
    ]);
    
    dd($request);
}

I dont know what am I doing wrong?I dont know what am I doing wrong? I dont know what am I doing wrong?

php artisan route:list

| POST   | term-one                  | term-one.store     | AppHttpControllersTermOneController@store                           | web                                                                         |
|        | GET|HEAD  | term-one                      | term-one.index     | AppHttpControllersTermOneController@index                           | web                                                                         |
|        | GET|HEAD  | term-one/create               | term-one.create    | AppHttpControllersTermOneController@create                          | web                                                                         |
|        | PUT|PATCH | term-one/{term_one}           | term-one.update    | AppHttpControllersTermOneController@update                          | web                                                                         |
|        | GET|HEAD  | term-one/{term_one}           | term-one.show      | AppHttpControllersTermOneController@show                            | web                                                                         |
|        | DELETE    | term-one/{term_one}           | term-one.destroy   | AppHttpControllersTermOneController@destroy                         | web                                                                         |
|        | GET|HEAD  | term-one/{term_one}/edit      | term-one.edit      | AppHttpControllersTermOneController@edit                            | web                                                                         |

Route File

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...