- $chapter = Chapter::visible()->with(['tags', 'createdBy', 'updatedBy', 'ownedBy', 'pages' => function (HasMany $query) {
- $query->scopes('visible')->get(['id', 'name', 'slug']);
- }])->findOrFail($id);
+ $chapter = $this->queries->findVisibleByIdOrFail(intval($id));
+ $chapter = $this->forJsonDisplay($chapter);
+
+ $chapter->load(['createdBy', 'updatedBy', 'ownedBy']);
+
+ // Note: More fields than usual here, for backwards compatibility,
+ // due to previously accidentally including more fields that desired.
+ $pages = $this->entityQueries->pages->visibleForChapterList($chapter->id)
+ ->addSelect(['created_by', 'updated_by', 'revision_count', 'editor'])
+ ->get();
+ $chapter->setRelation('pages', $pages);