我收到此错误:“传递给App \ Http \ Controllers \ Api \ CasasVendaController :: update()的参数2必须是Illuminate \ Http \ Request的实例,给定数组,在C:\ imoveis_backend \ imoveis中调用\ app \ Http \ Controllers \ Api \ CasasVendaController.php行103“
我只是在尝试HttpClient,现在不想创建服务和东西。我只是想测试我的后端而已。
this.httpClient.put('http://localhost:8000/api/casa-venda/' + this.id, {dormitorio: formulario.dormitorios, banheiro: formulario.banheiros }).subscribe(
res => {
}
后端是这样的:
public function update($id, Request $request)
{
$atributos = [
'dormitorio' => 1,
'banheiro' => 1
];
$this->update($id, $atributos);
}
)
我的路线::
Route::put('casa-venda/{id}', 'CasasVendaController@update');
答案 0 :(得分:2)
您在php方面遇到问题。将功能更改为
public function update(Request $request){
$atributos = [
'dormitorio' => 1,
'banheiro' => 1
];
//$this->update($id, $atributos);
}
)