moshaorui 1 kuukausi sitten
vanhempi
sitoutus
62e0a56282
1 muutettua tiedostoa jossa 7 lisäystä ja 2 poistoa
  1. 7 2
      routes/web.php

+ 7 - 2
routes/web.php

@@ -27,16 +27,21 @@ use App\Models\DistProductCategory;
 
 //巴西官网专用路由
 $host = $_SERVER['HTTP_HOST']; // 获取当前域名
+
 if ($host == 'internal-demo-site.mietubl.com.cn') {
     Route::get('/{slug}', function ($slug) {
         // 查询数据库,将 category_slug 转换为对应ID
-        $categoryId = DistProductCategory::where('slug',$slug)
+        $categoryId = DistProductCategory::where(function ($query) use ($slug) {
+            $query->where('slug', $slug);
+        })
             ->where('dist_id', getDistId())
-            ->firstOrFail();
+            ->first();
+
         if ($categoryId) {
             return redirect()->route('products.categories', ['slug' => $categoryId]);
         } else {
             $product = DistProduct::getProductSlug($slug);
+
             if ($product) {
                 return redirect()->route('products.detail', ['id' => $product->id]);
             }