【发布时间】:2019-05-26 14:55:09
【问题描述】:
大家好,今天我的 api 有这个问题。 我不更新数据库上的记录。 在邮递员中,响应是正确的,但不要保存在数据库中。 在 Postaman 中,我使用 PUT 方法传递并在正文名称中设置文本
产品控制器:
public function update(Request $request, $id)
{
$product = auth()->user()->products()->find($id);
if (!$product) {
return response()->json([
'success' => false,
'message' => 'Product with id ' . $id . ' not found'
], 400);
}
$updated = $product->fill($request->all())->save();
if ($updated)
return response()->json([
'success' => true
]);
else
return response()->json([
'success' => false,
'message' => 'Product could not be updated'
], 500);
}
【问题讨论】:
标签: api laravel-5 token updates