kphcdr 1 jaar geleden
bovenliggende
commit
5c0783482f
1 gewijzigde bestanden met toevoegingen van 5 en 1 verwijderingen
  1. 5 1
      app/Modules/Mini/Services/GoodsService.php

+ 5 - 1
app/Modules/Mini/Services/GoodsService.php

@@ -21,10 +21,14 @@ class GoodsService extends BaseService
 
         $goods->view_total++;
         $goods->save();
+        $gmap = $goods->map;
+        if (!\Auth::id()) {
+            $gmap = $goods->map->where("is_public", 1);
+        }
         return [
             "id" => $goods->id,
             "name" => $goods->name,
-            "category_name" => $goods->map->where("is_public", 1)->map(function (GoodsCategoryMap $map) {
+            "category_name" => $gmap->where("is_public", 1)->map(function (GoodsCategoryMap $map) {
                 return optional($map->category)->name;
             })->implode("/"),
             "image_list" => $goods->image_list,