Browse Source

feat:change product images

igb 4 months ago
parent
commit
37112d2b9f
1 changed files with 2 additions and 0 deletions
  1. 2 0
      app/Http/Controllers/ProductController.php

+ 2 - 0
app/Http/Controllers/ProductController.php

@@ -38,9 +38,11 @@ class ProductController extends Controller
 
         // 获取分类下的所有产品,并按 is_pinned 排序,然后进行分页
         $products = DistProduct::where('category_id', $category->id)
+            ->with('images') // Eager load images
             ->orderBy('is_pinned', 'desc') // 按 is_pinned 降序排序
             ->paginate(12);
 
+
         // 渲染模板并传递数据
         return $this->liquidRenderer->render('products_categories.liquid', [
             'category' => $category, // 分类名称