我正在使用Laravel创建RESTFUL应用程序,并使用Postman测试该应用程序。当前,PATCH或者PUT从Postman发送的带有表单数据的数据是否存在问题。
// Parameter `{testimonial}` will be sent to backend.
Route::post ('testimonials/{testimonial}', 'TestimonialController@update');
// Parameter `{testimonial}` will not be sent to backend (`$request->all()` will be empty) if sent from Postman with form-data.
Route::patch ('testimonials/{testimonial}', 'TestimonialController@update');
Route::put ('testimonials/{testimonial}', 'TestimonialController@update');
Run Code Online (Sandbox Code Playgroud)
$request->all()可以POST。$request->all()会好起来的PATCH,PUT和POST。PUT并PATCH使用表单数据,则$request->all()它将为空(参数将不会发送到后端)。现在,解决方案是POST用于更新模型。我想知道为什么PATCH和PUTPostman的表单数据一起发送时不起作用。