2017-10-20 124 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

相关问题