2017-10-20 122 views
-2

我是laravel中的新成員。 我收到此錯誤,當我點擊更新。MethodNotAllowedHttpException laravel 5.5

<form method="post" action="{{ route('companies.update',[$company->id]) }}"> 
{{ csrf_field() }} 
<input type="hidden" name="method" value="put"> 

enter image description here

+0

請顯示相關路線定義。 –

+2

我的第一印象是路由沒有在你的web.php中定義 – pseudoanime

+0

你的路由是Route :: get()還是Route :: post()?當你得到一個'MethodNotAllowedHttpException'時,這通常是首先要檢查的,所以包括你的'routes.php'或'routes/web.php'對於回答這個問題是非常有益的。 –

回答

1

更新您的name="method"name="_method"

所以

<input type="hidden" name="method" value="put">

應該

<input type="hidden" name="_method" value="PUT">

你也可以使用一個輔助生成輸入{{ method_field('PUT') }}

你可以看看關於它的文檔here

+0

感謝您快速回復。 '我得到了我的解決方案,在Composer.json中添加 「illuminate/html」:「〜5.0」 'Form'=>'Illuminate \ Html \ FormFacade', 'Html'=>'Illuminate \ Html \ HtmlFacade' , 我的app.php「別名」 – Sagor

相關問題