示例#1
0
 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");
 }
示例#3
0
 public function showBookOverview($id)
 {
     $book = Book::findOrFail($id);
     $edition = $book->lastEdition();
     return view('pages.book', compact(['book', 'edition']));
 }
示例#4
0
 public function deleteBook($id)
 {
     $book = Book::findOrFail($id);
     $book->delete();
     return redirect('/admin/books');
 }