use BookStack\Entities\EntityProvider;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Bookshelf;
+use BookStack\Entities\Models\Chapter;
+use BookStack\Entities\Models\Page;
use Illuminate\Support\Collection;
class SiblingFetcher
$entities = [];
// Page in chapter
- if ($entity->isA('page') && $entity->chapter) {
+ if ($entity instanceof Page && $entity->chapter) {
$entities = $entity->chapter->getVisiblePages();
}
// Page in book or chapter
- if (($entity->isA('page') && !$entity->chapter) || $entity->isA('chapter')) {
+ if (($entity instanceof Page && !$entity->chapter) || $entity instanceof Chapter) {
$entities = $entity->book->getDirectChildren();
}
// Book
// Gets just the books in a shelf if shelf is in context
- if ($entity->isA('book')) {
+ if ($entity instanceof Book) {
$contextShelf = (new ShelfContext())->getContextualShelfForBook($entity);
if ($contextShelf) {
$entities = $contextShelf->visibleBooks()->get();
}
}
- // Shelve
- if ($entity->isA('bookshelf')) {
+ // Shelf
+ if ($entity instanceof Bookshelf) {
$entities = Bookshelf::visible()->get();
}