/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update(BookRequest $request, $id) { $bookUpdate = $request->all(); $book = \App\Book::find($id); $book->update($bookUpdate); return redirect('books'); }
/** * Store a newly created resource in storage. * * @return Response */ public function store(BookRequest $request) { if (Input::file('cover')->isValid()) { $file = Input::file('cover'); $destinationPath = 'images/cover'; $fileName = rand(11111, 99999) . '_' . $file->getClientOriginalName(); Input::file('cover')->move($destinationPath, $fileName); $data = new Book(); $data->fill($request->all()); $data->cover = $fileName; $data->save(); return Redirect('admin/books')->with('successMessage', 'Berhasil menambah buku.'); } else { return Redirect()->back(); } }
public function update($id, BookRequest $request) { $book = Book::findOrFail($id); $book->update($request->all()); return redirect('books'); }