1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-31 15:24:31 +03:00

Aligned item creation wording and updated shelf-book-add logic

This commit is contained in:
Dan Brown
2019-04-15 20:43:25 +01:00
parent 84419005e7
commit 7f3f6e65b9
9 changed files with 55 additions and 35 deletions

View File

@ -577,6 +577,21 @@ class EntityRepo
$shelf->books()->sync($syncData);
}
/**
* 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]);
}
/**
* Change the book that an entity belongs to.
* @param string $type