public function savePhoto(Request $request, $bookId) { $this->validate($request, ['photo' => 'required|mimes:jpg,jpeg,png,bmp']); $book = Book::findOrFail($bookId); $photo = $request->file('photo'); (new AddPhotoToBook($book, $photo))->save(); }
public function saveEdition(Request $request, $bookId) { $this->validate($request, ['publisher' => 'required|max:255', 'published_at' => 'required|date', 'version' => 'required', 'pages' => 'required', 'price' => 'required']); $book = Book::findOrFail($bookId); $edition = new Edition($request->all()); $book->addEdition($edition); flash()->success('Created', 'New book edition has been created'); return redirect("/admin/books/{$bookId}/editions"); }
public function showBookOverview($id) { $book = Book::findOrFail($id); $edition = $book->lastEdition(); return view('pages.book', compact(['book', 'edition'])); }
public function deleteBook($id) { $book = Book::findOrFail($id); $book->delete(); return redirect('/admin/books'); }