/** * @param Page $page * @param PageRepositoryInterface $pages * @return Page */ public function show(Page $page, PageRepositoryInterface $pages) { $page->load($this->relations()); //make sure one cannot select itself as a subpage $but = new Collection([$page]); if ($page->parent) { $but->push($page->parent); } //make sure one cannot select a page B to add as a subpage to page A when page A is already a child of page B $availablePages = $pages->with(['translations'])->orphans()->but($but)->get(); $page->availablePages = $availablePages; $this->prepareMedia($page, ['images', 'videos', 'infographics', 'files']); return $page; }