user()->stores()->where('slug', $slug)->firstOrFail(); } private function cart(Request $request, Store $store): Cart { return new Cart($request->session(), $store); } /** * Every storefront page gets the same basics: the plan, the fonts, the product list and the cart. * * @param array $view Which page to show. */ private function renderStorefront(Request $request, Store $store, array $view): Response { abort_if($store->plan === null, 404); return Inertia::render('stores/preview', [ 'storeName' => $store->name, 'language' => $store->language->value, 'plan' => $store->plan, 'fonts' => PlanSchema::FONTS, // Links inside the storefront are built on top of this address. 'baseUrl' => route('stores.preview', $store->slug, false), 'view' => $view, 'products' => $store->products() ->active() ->with('images') ->latest('id') ->limit(60) ->get() ->map(fn (Product $product) => $product->toStorefront()), 'cart' => $this->cart($request, $store)->toStorefront(), ]); } }