laravel入門(俗にいう青本)という書籍の235ぺージを進めていたところ、次のエラーが出てしまいました。
Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
The GET method is not supported for this route. Supported methods: POST.
ゲットメソッドがサポートされていないということなのですが、原因がよくわかりません。
わかる方いましたら、回答お願いします。
php
1<?php 2 3namespace App\Http\Controllers; 4 5use App\Person; 6use Illuminate\Http\Request; 7 8class PersonController extends Controller 9{ 10 public function index(Request $request) 11 { 12 $items = Person::all(); 13 return view('person.index', ['items' => $items]); 14 } 15 16 public function find(Request $request) 17 { 18 return view('person.find', ['input' => '']); 19 } 20 21 public function search(Request $request) 22 { 23 $item = Person::find($request->input); 24 $param = ['input' => $request->input, 'item' => $item]; 25 return view('person.find', $param); 26 } 27} 28
php
1@extends('layouts.helloapp') 2 3@section('title', 'Person.find') 4 5@section('menubar') 6 @parent 7 検索ページ 8@endsection 9 10@section('content') 11 <form action="/person/find" method="post"> 12 {{csrf_field()}} 13 <input type="text" name="input" value="{{$input}}"> 14 <input type="submit" value="find"> 15 </form> 16 @if (isset($item)) 17 <table> 18 <tr><th>Data</th></tr> 19 <tr> 20 <td>{{$item->getData()}}</td> 21 </tr> 22 </table> 23 @endif 24@endsection 25 26@section('footer') 27copyright 2017 tuyano. 28@endsection
php
1<?php 2 3/* 4|-------------------------------------------------------------------------- 5| Web Routes 6|-------------------------------------------------------------------------- 7| 8| Here is where you can register web routes for your application. These 9| routes are loaded by the RouteServiceProvider within a group which 10| contains the "web" middleware group. Now create something great! 11| 12*/ 13//use App\Http\Middleware\HelloMiddleware; 14 15Route::get('hello', 'HelloController@index'); 16Route::get('person', 'PersonController@index'); 17Route::get('Person/find', 'PersonController@find'); 18Route::post('person/find', 'personController@search'); 19Route::post('hello', 'HelloController@post'); 20 21
どのように解決されたのでしょうか。
https://teratail.com/help/question-tips#questionTips4-2
放置して次の質問を立てられたわけですし、結局何もコメントがないまま解決済みに選んだだけになると
この質問もそれについた回答も無駄になります。
むしろ、PHPすら理解が薄いままLaravelを強引に進めるのは遠回りということを理解されたのでしょうか?

回答1件
あなたの回答
tips
プレビュー