我是laravel中的新成員。 我收到此錯誤,當我點擊更新。MethodNotAllowedHttpException laravel 5.5
<form method="post" action="{{ route('companies.update',[$company->id]) }}">
{{ csrf_field() }}
<input type="hidden" name="method" value="put">
我是laravel中的新成員。 我收到此錯誤,當我點擊更新。MethodNotAllowedHttpException laravel 5.5
<form method="post" action="{{ route('companies.update',[$company->id]) }}">
{{ csrf_field() }}
<input type="hidden" name="method" value="put">
更新您的name="method"
到name="_method"
所以
<input type="hidden" name="method" value="put">
應該
<input type="hidden" name="_method" value="PUT">
你也可以使用一個輔助生成輸入{{ method_field('PUT') }}
你可以看看關於它的文檔here。
感謝您快速回復。 '我得到了我的解決方案,在Composer.json中添加 「illuminate/html」:「〜5.0」 'Form'=>'Illuminate \ Html \ FormFacade', 'Html'=>'Illuminate \ Html \ HtmlFacade' , 我的app.php「別名」 – Sagor
請顯示相關路線定義。 –
我的第一印象是路由沒有在你的web.php中定義 – pseudoanime
你的路由是Route :: get()還是Route :: post()?當你得到一個'MethodNotAllowedHttpException'時,這通常是首先要檢查的,所以包括你的'routes.php'或'routes/web.php'對於回答這個問題是非常有益的。 –