我有要求:
store
我在方法update
和update
的控制器上调用了此请求。用store方法都可以,因为方法POST。但是在方法update
中请求是PATCH。
当我调用方法Method App\Http\Requests\EsRequest::add does not exist.
时,我收到错误:
Route::post('/postadd', 'Post\PostController@store')->name('addpost');
Route::patch('/post/update/{id}', 'Post\PostController@update')->name('editpost');
我如何解决这个问题?
路线:
public function update(EsRequest $request, $id)
{
$post = Post::findOrFail($id);
$request->add(['data' => $request->extra]);
$post->update($request->all());
return back();
}
控制器:
/* Added */
.content_section.with_border {
position: relative;
}
.content_section.with_border:before {
content: "";
width: 10%;
display: block;
height: 2px;
left: 0;
bottom: -4px; /* modified top -> bottom, value can be modified to adjust position */
position: absolute;
background: #1d1b22;
clear: both;
}
.content_section.with_border .label {
position: relative;
clear: both;
}
h1,
h2 {
font-weight: 800;
font-size: 1.60714em;
line-height: 1.24444em;
margin: 0 0 .64286em;
}
.content_section.with_border .content {
padding: 0 11%;
clear: both;
}
.content_section .label {
font-size: .5em;
text-transform: uppercase;
font-weight: 800;
}
答案 0 :(得分:1)
$request
支持集合功能。要添加新参数,您只需执行以下操作:
$request['data'] = ['foo' => 'bar'];
或使用收集方法:
$request->put('data', ['foo' => 'bar']);