@@ -26,6 +26,9 @@ |
||
| 26 | 26 | $child2 = Factory::create(new Category, ['name' => 'Child 2', 'slug' => 'child-2', 'parent_id' => $parent2->id]); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | + /** |
|
| 30 | + * @param integer $count |
|
| 31 | + */ |
|
| 29 | 32 | protected function seedProducts($count) |
| 30 | 33 | { |
| 31 | 34 | $categories = Category::count(); |
@@ -20,10 +20,10 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | protected function seedCategories() |
| 22 | 22 | { |
| 23 | - $parent1 = Factory::create(new Category, ['name' => 'Parent 1', 'slug' => 'parent-1']); |
|
| 24 | - $parent2 = Factory::create(new Category, ['name' => 'Parent 2', 'slug' => 'parent-2']); |
|
| 25 | - $child1 = Factory::create(new Category, ['name' => 'Child 1', 'slug' => 'child-1', 'parent_id' => $parent1->id]); |
|
| 26 | - $child2 = Factory::create(new Category, ['name' => 'Child 2', 'slug' => 'child-2', 'parent_id' => $parent2->id]); |
|
| 23 | + $parent1 = Factory::create(new Category, [ 'name' => 'Parent 1', 'slug' => 'parent-1' ]); |
|
| 24 | + $parent2 = Factory::create(new Category, [ 'name' => 'Parent 2', 'slug' => 'parent-2' ]); |
|
| 25 | + $child1 = Factory::create(new Category, [ 'name' => 'Child 1', 'slug' => 'child-1', 'parent_id' => $parent1->id ]); |
|
| 26 | + $child2 = Factory::create(new Category, [ 'name' => 'Child 2', 'slug' => 'child-2', 'parent_id' => $parent2->id ]); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | protected function seedProducts($count) |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | $categories = Category::count(); |
| 32 | 32 | |
| 33 | 33 | for ($i = 0; $i < $count; $i++) { |
| 34 | - $product = Factory::create(new Product, ['name' => 'Product ' . $i, 'slug' => 'product-' . $i]); |
|
| 35 | - $product->categories()->sync([rand(1, $categories)]); |
|
| 34 | + $product = Factory::create(new Product, [ 'name' => 'Product '.$i, 'slug' => 'product-'.$i ]); |
|
| 35 | + $product->categories()->sync([ rand(1, $categories) ]); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | } |