I have a laravel project which is in laravel 5.5. I have manually created an extra field "uploaded_image" in the existing "product" table. When I passed the data into the laravel controller (ProductController.php), all the existing fields are updated except the newly created field. Below is my ProductController code:
public function update(Request $request, $id)
{
$data = $request->validate([
'product_name' => 'required',
'description' => 'required',
'rating' => 'required'
]);
$uploaded_image = $request->input('uploaded_image');
$data['uploaded_image'] = $uploaded_image['filename']; // which is abc.png
$product = Product::findOrFail($id);
$product->update($data);
return response()->json($data);
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire