/**
  * Create a fake product.
  */
 private function seedProduct()
 {
     $product = Product::create(['name' => sprintf('%s %s', ucwords($this->faker()->words(3, true)), '3D Pop-Up Greetings Card'), 'sku' => mb_strtoupper($this->faker()->lexify('?????')), 'slug' => $this->faker()->slug(), 'description' => $this->faker()->paragraph, 'supplier_number' => $this->faker()->unique()->numberBetween(1000, 10000)]);
     $imagesIDs = [];
     foreach ($this->makeImages() as $image) {
         $imagesIDs[] = $image->id;
     }
     $product->attachImages($imagesIDs);
     $price = new Price(['units' => random_int(1, 100), 'subunits' => random_int(0, 99), 'currency' => 'GBP']);
     $product->prices()->save($price);
     for ($i = 0, $count = random_int(1, 3); $i < $count; $i++) {
         $this->addProductOption($product);
     }
 }
Example #2
0
 /**
  * @param array $attributes
  *
  * @return Product
  */
 protected function createProduct(array $attributes = []) : Product
 {
     return Product::create(array_merge(['name' => uniqid('', false), 'sku' => uniqid('SKU', false), 'slug' => uniqid('slug-', false), 'description' => 'Description ' . str_random(30)], $attributes));
 }
 /**
  * @param array $productData
  *
  * @return Product
  */
 public function create(array $productData) : Product
 {
     return $this->productResource->create($productData);
 }