X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/6cd26e23a800b35a5f83df77cb723d00c70a2dec..refs/pull/2382/head:/app/Http/Controllers/BookshelfController.php diff --git a/app/Http/Controllers/BookshelfController.php b/app/Http/Controllers/BookshelfController.php index 5c9da762f..50dc97bab 100644 --- a/app/Http/Controllers/BookshelfController.php +++ b/app/Http/Controllers/BookshelfController.php @@ -1,8 +1,8 @@ bookshelfRepo = $bookshelfRepo; $this->entityContextManager = $entityContextManager; $this->imageRepo = $imageRepo; - parent::__construct(); } /** @@ -85,14 +84,13 @@ class BookshelfController extends Controller $this->validate($request, [ 'name' => 'required|string|max:255', 'description' => 'string|max:1000', - 'image' => $this->getImageValidationRules(), + 'image' => 'nullable|' . $this->getImageValidationRules(), ]); $bookIds = explode(',', $request->get('books', '')); $shelf = $this->bookshelfRepo->create($request->all(), $bookIds); - $this->bookshelfRepo->updateCoverImage($shelf); + $this->bookshelfRepo->updateCoverImage($shelf, $request->file('image', null)); - Activity::add($shelf, 'bookshelf_create'); return redirect($shelf->getUrl()); } @@ -103,11 +101,11 @@ class BookshelfController extends Controller public function show(string $slug) { $shelf = $this->bookshelfRepo->getBySlug($slug); - $view = setting()->getForCurrentUser('books_view_type', config('app.views.books')); $this->checkOwnablePermission('book-view', $shelf); Views::add($shelf); $this->entityContextManager->setShelfContext($shelf->id); + $view = setting()->getForCurrentUser('bookshelf_view_type', config('app.views.books')); $this->setPageTitle($shelf->getShortName()); return view('shelves.show', [ @@ -148,7 +146,7 @@ class BookshelfController extends Controller $this->validate($request, [ 'name' => 'required|string|max:255', 'description' => 'string|max:1000', - 'image' => $this->imageRepo->getImageValidationRules(), + 'image' => 'nullable|' . $this->getImageValidationRules(), ]); @@ -156,7 +154,6 @@ class BookshelfController extends Controller $shelf = $this->bookshelfRepo->update($shelf, $request->all(), $bookIds); $resetCover = $request->has('image_reset'); $this->bookshelfRepo->updateCoverImage($shelf, $request->file('image', null), $resetCover); - Activity::add($shelf, 'bookshelf_update'); return redirect($shelf->getUrl()); } @@ -182,7 +179,6 @@ class BookshelfController extends Controller $shelf = $this->bookshelfRepo->getBySlug($slug); $this->checkOwnablePermission('bookshelf-delete', $shelf); - Activity::addMessage('bookshelf_delete', $shelf->name); $this->bookshelfRepo->destroy($shelf); return redirect('/shelves');