* * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $update = [ 'title' => $request->title, 'author' => $request->author, 'published_year' => $request->published_year ]; $book = Book::where('id', $id)->update($update); if ($book) { return response()->json( $book, 201 ); } else { return response()->json([ 'message' => 'Book not found', ], 404); } }