The DB::update query needs sorting so that I can update the values where id = $id;
Dec 7, 2019
11
Level 3
DB::update query
I am trying to use the query using the valided values, $book_name, $isbn_no & $book_price and ofcourse the $Id but the query doesn't work.
public function update(Request $request, $id) {
$validatedData = $request->validate([
'book_name' => 'required|max:255',
'isbn_no' => 'required|alpha_num',
'book_price' => 'required|numeric',
]);
$book_name = $validatedData['book_name']; $isbn_no = $validatedData['isbn_no']; $book_price = $validatedData['book_price'];
DB::update('update Books (book_name, isbn_no, book_price) value (?,?,?), [$book_name, $isbn_no, $book_price] where id = $id');
return redirect('/books')->with('success', 'Book is successfully updated'); }
Please or to participate in this conversation.