protected function assignShippingPlanToProduct(Product $product) : ShippingPlan
 {
     $seller = $product->getSeller();
     if (!$seller->hasShippingPlans()) {
         $this->seedShipping($seller);
     }
     $product->setShippingPlan($shippingPlan = $seller->getShippingPlans()->random());
     return $shippingPlan;
 }
 protected function assignAttributesToProduct(Product $product, $attributeOptions = null)
 {
     /** @var Shop $seller */
     $seller = $product->getSeller();
     if (!$seller->hasAttributeGroups()) {
         $this->seedAttributes($seller);
     }
     $attributeOptions = $attributeOptions ?: $seller->attributeGroups()->with('attributeOptions')->get()->pluck('attributeOptions')->flatten(1)->pluck('id')->toArray();
     $product->setAttributeOptions($attributeOptions, true);
     app(VariantManager::class)->refreshVariants($product);
 }
 public function show(Product $product, VariantManager $variantManager, AttributeManager $attributeManager)
 {
     if (!$product->isActive()) {
         abort(404);
     }
     $seller = $product->getSeller();
     $attributes = $attributeManager->getAttributesForProduct($product);
     $variants = $variantManager->getVariantRepository()->whereProduct($product)->with('attributeOptions')->findAll();
     // for stock calculation
     $product->setRelation('variants', $variants);
     return view('product::__front.products.show', compact('seller', 'product', 'attributes', 'variants'));
 }