Browse Source

Merge branch 'refs/heads/master' into stable

moshaorui 3 weeks ago
parent
commit
d69a20b8e9

+ 13 - 1
app/Http/Controllers/ProductController.php

@@ -42,8 +42,20 @@ class ProductController extends Controller
             ->where('dist_id', getDistId())
             ->firstOrFail();
 
+        if (!$category) {
+            abort('404');
+        }
+        $categoryIds = [$category->id];
+        if ($category) {
+            //找下一级分类
+            $subCategories = DistProductCategory::where('parent_id', $category->id)->get();
+            foreach ($subCategories as $subCategory) {
+                $categoryIds[] = $subCategory->id;
+            }
+        }
+
         // 获取分类下的所有产品,排序,然后进行分页
-        $products = DistProduct::where('category_id', $category->id)
+        $products = DistProduct::whereIn('category_id', $categoryIds)
             ->where('dist_id', getDistId())
             ->where('enabled', 1)
             ->where('status', 2)

+ 11 - 1
app/Services/LiquidTags/LiquidTagCollection.php

@@ -66,8 +66,18 @@ class LiquidTagCollection extends AbstractBlock
             return ''; // 如果没有找到页面,返回空字符串
         }
 
+        $pagesData = [];
+        $items = $pages->items();
+        if ($items) {
+            $i = 0;
+            foreach ($items as $item) {
+                $pagesData[$i] = $item;
+                $pagesData[$i]['tags'] = $item->tags->toArray();
+                $i++;
+            }
+        }
         // 如果有文章,渲染模板
-        return $this->renderTemplate(['pages' => $pages->items()]);
+        return $this->renderTemplate(['pages' => $pagesData]);
     }
 
     // 渲染模板

+ 5 - 0
routes/web.php

@@ -29,6 +29,11 @@ $host = request()->getHttpHost();    // 安全且可靠
 $uri = request()->getRequestUri();
 $brHost = env('BR_HOST'); // 巴西官网域名
 if ($host == $brHost) {
+    $questionMarkPosition = strpos($uri, '?');
+    if ($questionMarkPosition !== false) {
+        // 截取问号前面的部分
+        $uri = substr($uri, 0, $questionMarkPosition);
+    }
     $segments = explode('/', $uri);
     if ($segments) {
         $slug = $segments[1];