getPageByPath($path); $this->handleCheckNotFoundStatusCode($page); $subSectionPages = $page->section ? PageResource::collection($page->section->pages) : null; $seo = $this->seoPageProvider->getSeoForModel($page); $pageResource = new PageResource($page); $this->handlePageStatusCode($pageResource); return inertia()->render('Page', [ 'page' => $pageResource, 'subSectionPages' => $subSectionPages, 'seo' => $seo, ]); } private function handlePageStatusCode(PageResource $pageResource): void { if ($pageResource->code != 200) { abort($pageResource->code); } } private function handleCheckNotFoundStatusCode($page): void { if ($page === null) { abort(404); } } public function getPageByPath(string $path): ?Page { $cacheKey = 'page_' . md5($path); return Cache::remember($cacheKey, now()->addHours(48), function () use ($path) { return Page::where('path', '=', $path) ->with('section.pages.section', 'section.mainSection') ->first(); }); } }