laravel更新数据库记录的坑Missing required
2017-11-28 本文已影响371人
9b559869875b
1. laravel更新blog的页面报错
Missing required parameters for [Route: post.update] [URI: post/{post}].
(View: resources/views/blog_posts_edit.blade.php)
这是因为update需要指定文章的id号,把$post->id传进去就好了
{!! Form::open(array('action' => array('PostController@update',$post->id))) !!}
2. 但是接着又报错了,MethodNotAllowedHttpException
需要加个method,参考:https://stackoverflow.com/a/39685652
{!! Form::open(array('route' => array('post.update', $post->id),'method' => 'PUT')) !!}
3. 另外,可以用post.update来代替route名字,post是Route::resource里的资源名
{!! Form::open(array('route' => array('post.update', $post->id))) !!}