lundi 27 avril 2020

How to fix Laravel api update not working?

I want to update a review by ID using the following link in Postman http://localhost:8000/api/v1/reviews/2

I have the following in the ReviewController

public function update(Request $request,Product $product, Review $review)
      {
          $review->update($request->all());
                  // $review->save();
          return response([
              'data' => new ReviewResource($review)
          ],Response::HTTP_CREATED);
      }

When trying to update content for null fields for booktitle and description using PUT method I get a success message however the record remains the same. It is not updated.

This is the review model file

<?php

namespace App\Model;

use App\Model\Product;
use Illuminate\Database\Eloquent\Model;

class Review extends Model
{
    public $timestamps = true;

    protected $fillable = [
    'booktitle', 'description', 'updated_at', 'created_at',
    ];



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/35a4tHN
via IFTTT

Aucun commentaire:

Enregistrer un commentaire