Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

CompanyProfileFactory.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Database\Factories\Setting;
  3. use App\Enums\EntityType;
  4. use App\Models\Setting\CompanyProfile;
  5. use Illuminate\Database\Eloquent\Factories\Factory;
  6. /**
  7. * @extends Factory<CompanyProfile>
  8. */
  9. class CompanyProfileFactory extends Factory
  10. {
  11. /**
  12. * @var string The related model's name.
  13. */
  14. protected $model = CompanyProfile::class;
  15. /**
  16. * Define the model's default state.
  17. *
  18. * @return array<string, mixed>
  19. */
  20. public function definition(): array
  21. {
  22. return [
  23. 'address' => $this->faker->streetAddress,
  24. 'city' => $this->faker->city,
  25. 'zip_code' => $this->faker->postcode,
  26. 'country' => $this->faker->randomElement(CompanyProfile::getAvailableCountryCodes()),
  27. 'phone_number' => $this->faker->e164PhoneNumber,
  28. 'email' => $this->faker->email,
  29. 'entity_type' => $this->faker->randomElement(EntityType::class),
  30. 'fiscal_year_start' => (new \DateTime('first day of January'))->format('Y-m-d'),
  31. 'fiscal_year_end' => (new \DateTime('last day of December'))->format('Y-m-d'),
  32. ];
  33. }
  34. public function configure(): static
  35. {
  36. return $this->afterCreating(function (CompanyProfile $companyProfile) {
  37. $companyProfile->timezone = $this->faker->randomElement(CompanyProfile::getTimezoneOptions($companyProfile->country));
  38. $companyProfile->state = $this->faker->randomElement(CompanyProfile::getStateOptions($companyProfile->country));
  39. $companyProfile->save();
  40. });
  41. }
  42. }