search

Home  >  Q&A  >  body text

An error occurred when Laravel used the post method, but the get method can be run.

The controller is as follows. View a search box and submit it to the search method of the controller below:

1

2

3

4

5

6

7

<code>    public function search(Request $request)

    {

        $keywords= $request->input('keywords');

        $articles = Article::search($keywords)->get();

        return view('pages.search-list', compact('articles'));

    }

</code>

The result can be obtained normally using the get method, but the following error occurs when using the post method:

Want to know why.

淡淡烟草味淡淡烟草味2804 days ago783

reply all(1)I'll reply

  • 阿神

    阿神2017-05-16 16:52:36

    I guess your form uses post, but your route is Route::get();

    reply
    0
  • Cancelreply