AttributeTableSeeder.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. use App\Shop\Attributes\Attribute;
  3. use App\Shop\AttributeValues\AttributeValue;
  4. use Illuminate\Database\Seeder;
  5. class AttributeTableSeeder extends Seeder
  6. {
  7. public function run()
  8. {
  9. $sizeAttr = factory(Attribute::class)->create(['name' => 'Size']);
  10. factory(AttributeValue::class)->create([
  11. 'value' => 'small',
  12. 'attribute_id' => $sizeAttr->id
  13. ]);
  14. factory(AttributeValue::class)->create([
  15. 'value' => 'medium',
  16. 'attribute_id' => $sizeAttr->id
  17. ]);
  18. factory(AttributeValue::class)->create([
  19. 'value' => 'large',
  20. 'attribute_id' => $sizeAttr->id
  21. ]);
  22. $colorAttr = factory(Attribute::class)->create(['name' => 'Color']);
  23. factory(AttributeValue::class)->create([
  24. 'value' => 'red',
  25. 'attribute_id' => $colorAttr->id
  26. ]);
  27. factory(AttributeValue::class)->create([
  28. 'value' => 'yellow',
  29. 'attribute_id' => $colorAttr->id
  30. ]);
  31. factory(AttributeValue::class)->create([
  32. 'value' => 'blue',
  33. 'attribute_id' => $colorAttr->id
  34. ]);
  35. }
  36. }