featured() ->orderBy('sort') ->orderByDesc('hot_score') ->limit($featuredLimit) ->get(); $newProducts = Product::published() ->orderByDesc('sort') ->orderByDesc('created_at') ->limit($newLimit) ->get(); $categories = Category::with([ 'children', 'products' => function ($query) use ($categoryLimit) { $query->published() ->orderBy('sort') ->orderByDesc('hot_score') ->limit($categoryLimit); }, ]) ->whereNull('parent_id') ->orderBy('sort') ->get(); return view('frontend.home', [ 'featuredProducts' => $featuredProducts, 'newProducts' => $newProducts, 'categories' => $categories, ]); } }