[ 'user' => $request->user() ? $request->user()->only('id', 'name', 'email', 'created_at') : null, ], // 'ziggy' => fn () => [ // ...(new Ziggy)->toArray(), // 'location' => $request->url(), // ], 'ziggy' => function() { return array_merge((new Ziggy())->toArray(), [ 'location' => url()->current(), ]); }, 'navigation' => $this->getNavigation(), 'breadcrumbs' => $this->getBreadcrumbs(), 'urlPrev' => function () { if (url()->previous() !== url()->current()) { return url()->previous(); } return 'empty'; }, ]; } private function getNavigation() { return Cache::remember('navigation', now()->addHours(1), function () { return NavigationResource::collection( MainSection::with('subSections.pages.section') ->orderBy('sort', 'asc') ->get() ); }); } private function getBreadcrumbs() { return app(BreadcrumbService::class)->generateBreadcrumbs(); } }