- $entity = $this->entityRepo->getById($type, $id);
- if (!$entity) {
- return $this->jsonError(trans('errors.entity_not_found'), 404);
- }
-
- $entities = [];
-
- // Page in chapter
- if ($entity->isA('page') && $entity->chapter) {
- $entities = $this->entityRepo->getChapterChildren($entity->chapter);
- }
-
- // Page in book or chapter
- if (($entity->isA('page') && !$entity->chapter) || $entity->isA('chapter')) {
- $entities = $this->entityRepo->getBookDirectChildren($entity->book);
- }
-
- // Book in shelf
- // TODO - When shelve tracking added, Update below if criteria
-
- // Book
- if ($entity->isA('book')) {
- $entities = $this->entityRepo->getAll('book');
- }
-
- // Shelve
- // TODO - When shelve tracking added