Запись обновления Laravel с помощью PassportPhp

Кемеровские программисты php общаются здесь
Anonymous
Запись обновления Laravel с помощью Passport

Сообщение Anonymous »

У меня проблема с моим API.
Я не обновляю запись в базе данных.
В Postman ответ верен, но не сохраняется в базе данных.
В Postman Я передал метод PUT и установил в поле «Имя тела» текст.
ProductController:

Код: Выделить всё

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);
}
Изображение


Подробнее здесь: https://stackoverflow.com/questions/563 ... h-passport

Вернуться в «Php»