/** * {@inheritdoc} */ public function build($name, $sku, $price, $stockQty) { DB::beginTransaction(); $this->product = Product::firstOrCreateByName($name); // Set Base Varient $variant = new Variant(); $variant->sku = $sku; $variant->price = $price; $variant->on_hand = $stockQty; $variant->product_id = $this->product->id; $variant->master = true; $variant->available_on_demand = false; $variant->save(); return $this; }
private function getInstance($id = null) { if (isset($id)) { return Variant::find($id); } return new Variant(); }