*/ final class ProductFactory extends Factory { /** * The name of the factory's corresponding model. * * @var string */ protected $model = Product::class; /** * Define the model's default state. * * @return array */ public function definition(): array { $label = fake()->unique()->word; $list = ['en' => []]; for ($jj = 1; $jj <= 6; $jj++) { array_push($list['en'], [ "value" => fake()->unique()->words(\rand(2, 8), true) ]); } $nutritionnal_values = ['en' => []]; for ($jj = 1; $jj <= 9; $jj++) { array_push($nutritionnal_values['en'], [ "label" => fake()->unique()->words(\rand(2, 8), true), "value" => fake()->unique()->words(2, true) ]); } return [ 'seo_title' => fake()->word, 'seo_description' => fake()->text, 'label' => $label, 'slug' => Str::slug($label), 'description' => fake()->word, 'picture_alt' => fake()->word, 'picture_title' => fake()->word, 'certifications' => [\collect(CertificationsEnum::cases())->random()], 'nutritionnal_values' => $nutritionnal_values, 'list' => $list, 'status' => fake()->boolean(75), 'range_id' => fake()->randomElement(Range::pluck('id')), ]; } }