查看商品优化
parent
4c863302fa
commit
1ac886306b
|
|
@ -45,17 +45,6 @@ class ProductSkuController extends Controller
|
||||||
|
|
||||||
$sku = ProductSku::with('buynote')->findOrFail($id);
|
$sku = ProductSku::with('buynote')->findOrFail($id);
|
||||||
|
|
||||||
// 是否收藏商品
|
|
||||||
$isCollected = (bool) $user?->skuFavorites()->where('sku_id', $sku->id)->exists();
|
|
||||||
|
|
||||||
if (! $sku->isOnline()) {
|
|
||||||
return response()->json([
|
|
||||||
'spu_specs' => [],
|
|
||||||
'sku' => ProduckSkuResource::make($sku),
|
|
||||||
'is_collected' => $isCollected,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$spu = ProductSpu::with('specs')->findOrFail($sku->spu_id);
|
$spu = ProductSpu::with('specs')->findOrFail($sku->spu_id);
|
||||||
|
|
||||||
// 主商品的规格
|
// 主商品的规格
|
||||||
|
|
@ -98,6 +87,9 @@ class ProductSkuController extends Controller
|
||||||
|
|
||||||
Viewed::dispatch($user, $sku, now());
|
Viewed::dispatch($user, $sku, now());
|
||||||
|
|
||||||
|
// 是否收藏商品
|
||||||
|
$isCollected = (bool) $user?->skuFavorites()->where('sku_id', $sku->id)->exists();
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'spu_specs' => $spuSpecs,
|
'spu_specs' => $spuSpecs,
|
||||||
'sku' => ProduckSkuResource::make($sku),
|
'sku' => ProduckSkuResource::make($sku),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue