Exemplo n.º 1
0
 protected function baseProperties()
 {
     factory(PropertyUnit::class)->times(35)->create();
     $units = PropertyUnit::all();
     foreach (Category::all() as $category) {
         $groups = factory(PropertyGroup::class)->times(4)->create(['category_id' => $category->id]);
         factory(Property::class, 'numeric')->times(4)->create(['unit_id' => $units->random(1)->id, 'group_id' => $groups->random(1)->id, 'category_id' => $category->id]);
         factory(Property::class, 'boolean')->times(5)->create(['group_id' => $groups->random(1)->id, 'category_id' => $category->id]);
         factory(Property::class, 'float')->times(1)->create(['group_id' => $groups->random(1)->id, 'category_id' => $category->id]);
         factory(Property::class, 'string')->times(3)->create(['group_id' => $groups->random(1)->id, 'category_id' => $category->id]);
         factory(Property::class, 'options')->times(3)->create(['group_id' => $groups->random(1)->id, 'category_id' => $category->id])->each(function ($property) {
             factory(PropertyOption::class)->times(rand(4, 10))->create(['property_id' => $property->id]);
         });
     }
 }