1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Moved shelf book append logic

This commit is contained in:
Dan Brown
2019-09-19 18:20:09 +01:00
parent 615b2de433
commit f7a5a0705b
3 changed files with 18 additions and 20 deletions

View File

@ -3,9 +3,7 @@
namespace BookStack\Entities\Repos;
use BookStack\Entities\Book;
use BookStack\Entities\Bookshelf;
use BookStack\Exceptions\NotFoundException;
use BookStack\Exceptions\NotifyException;
@ -25,21 +23,6 @@ class BookRepo extends EntityRepo
return $book;
}
/**
* Append a Book to a BookShelf.
* @param Bookshelf $shelf
* @param Book $book
*/
public function appendBookToShelf(Bookshelf $shelf, Book $book)
{
if ($shelf->contains($book)) {
return;
}
$maxOrder = $shelf->books()->max('order');
$shelf->books()->attach($book->id, ['order' => $maxOrder + 1]);
}
/**
* Destroy the provided book and all its child entities.
* @param Book $book