商品购买须知
parent
f88a9b0e5b
commit
adc099d6f6
|
|
@ -43,7 +43,7 @@ class ProductSkuController extends Controller
|
|||
{
|
||||
$user = $request->user();
|
||||
|
||||
$sku = ProductSku::findOrFail($id);
|
||||
$sku = ProductSku::with('buynote')->findOrFail($id);
|
||||
|
||||
// 是否收藏商品
|
||||
$isCollected = (bool) $user?->skuFavorites()->where('sku_id', $sku->id)->exists();
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ class ProduckSkuResource extends JsonResource
|
|||
'stock' => $this->saleable_stock,
|
||||
'weight' => (int) $this->weight,
|
||||
'is_online' => $this->isOnline(),
|
||||
'buynote' => (string) $this->when($this->relationLoaded('buynote'), function () {
|
||||
return $this->buynote?->content;
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,14 @@ class ProductSku extends Model
|
|||
return $this->hasMany(ProductGift::class, 'sku_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 此商品的购买须知
|
||||
*/
|
||||
public function buynote()
|
||||
{
|
||||
return $this->belongsTo(ProductBuynote::class, 'buynote_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认此商品是否已上架
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue