You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DiscountFactory.php 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace Database\Factories;
  3. use App\Models\Setting\Discount;
  4. use Illuminate\Database\Eloquent\Factories\Factory;
  5. /**
  6. * @extends Factory<Discount>
  7. */
  8. class DiscountFactory extends Factory
  9. {
  10. /**
  11. * The name of the factory's corresponding model.
  12. *
  13. * @var string
  14. */
  15. protected $model = Discount::class;
  16. /**
  17. * Define the model's default state.
  18. *
  19. * @return array<string, mixed>
  20. */
  21. public function definition(): array
  22. {
  23. $startDate = $this->faker->dateTimeBetween('now', '+1 year');
  24. $endDate = $this->faker->dateTimeBetween($startDate, strtotime('+1 year'));
  25. return [
  26. 'description' => $this->faker->sentence,
  27. 'rate' => $this->faker->randomFloat(4, 0, 20),
  28. 'computation' => $this->faker->randomElement(Discount::getComputationTypes()),
  29. 'scope' => $this->faker->randomElement(Discount::getDiscountScopes()),
  30. 'start_date' => $startDate,
  31. 'end_date' => $endDate,
  32. ];
  33. }
  34. }