where('type', StaticPageType::products)->firstOrFail(); $rangeModels = Range::query() ->where('status', true) ->whereHas('products', fn(Builder $q) => $q->where('status', true)) ->with('products', fn(Builder $q) => $q->where('status', true)->orderBy('order')) ->orderBy('order') ->get(); return view('fo.pages.products.index', compact('staticPageModel', 'rangeModels')); } /** * Product show. * * @param \App\Models\Product $publishedProduct * @return \Illuminate\Contracts\View\View */ public function show(Product $publishedProduct): \Illuminate\Contracts\View\View { $staticPageModel = StaticPage::query()->where('type', StaticPageType::product)->firstOrFail(); return view('fo.pages.products.show', [ 'staticPageModel' => $staticPageModel, 'productModel' => $publishedProduct, ]); } }