Answer the question
In order to leave comments, you need to log in
Error when editing an author's book, how can I solve it?
Here is the error itself:
General error: 1366 Incorrect integer value: 'PUT' for column 'author_id' at row 1 (SQL: insert into `book_author` (`author_id`, `book_id`) values (PUT, 1))
public function edit($id)
{
$book = Book::find($id);
$author = Author::all()->pluck('name', 'id')->toArray();
return view('book.edit',compact('book', 'author'));
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$book=Book::findOrFail($id, ['id']);
$book->authors()->sync($request->except('authors'));
return redirect()->route('books.index', compact('book'))
->with('success','Книга обновлена');
}
Answer the question
In order to leave comments, you need to log in
write a function in js that will wrap each word in a span and set a background for all these spans (well, other styles).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question