0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-21 07:26:59 +00:00

Started work on hierachy conversion actions

- Updates book/shelf cover image handling for easier cloning/handling.
- Adds core logic for promoting books/chapters up a level.
- Enables usage of book/shelf cover image via API.

Related to 
This commit is contained in:
Dan Brown 2022-06-13 17:20:21 +01:00
parent 0a05119aa5
commit d676e1e824
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9
10 changed files with 166 additions and 72 deletions
app/Http/Controllers

View file

@ -100,7 +100,6 @@ class BookController extends Controller
}
$book = $this->bookRepo->create($request->all());
$this->bookRepo->updateCoverImage($book, $request->file('image', null));
if ($bookshelf) {
$bookshelf->appendBook($book);
@ -158,15 +157,20 @@ class BookController extends Controller
{
$book = $this->bookRepo->getBySlug($slug);
$this->checkOwnablePermission('book-update', $book);
$this->validate($request, [
$validated = $this->validate($request, [
'name' => ['required', 'string', 'max:255'],
'description' => ['string', 'max:1000'],
'image' => array_merge(['nullable'], $this->getImageValidationRules()),
]);
$book = $this->bookRepo->update($book, $request->all());
$resetCover = $request->has('image_reset');
$this->bookRepo->updateCoverImage($book, $request->file('image', null), $resetCover);
if ($request->has('image_reset')) {
$validated['image'] = null;
} else if (is_null($validated['image'])) {
unset($validated['image']);
}
$book = $this->bookRepo->update($book, $validated);
return redirect($book->getUrl());
}