protected function prices(Product $product, $account) { $count = rand(1, 2); $counter = 0; while ($counter < $count) { $product->priceHistory()->save(new Price(['account_id' => $account, 'active_from' => $this->faker->dateTimeBetween('-3 years', '-5 months'), 'active_to' => $this->faker->dateTimeBetween('-5 months', '-2 days'), 'value' => rand(1000, 200000) / 10])); $counter++; } if (rand(0, 1)) { $product->price()->save(new ActivePrice(['account_id' => $account, 'activated_on' => $this->faker->dateTimeBetween('-6 months', '-2 days'), 'value' => rand(1000, 200000) / 10])); } }