Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

CompanyProfileFactory.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Database\Factories\Setting;
  3. use App\Enums\EntityType;
  4. use App\Events\CompanyGenerated;
  5. use App\Models\Setting\CompanyProfile;
  6. use Illuminate\Database\Eloquent\Factories\Factory;
  7. /**
  8. * @extends Factory<CompanyProfile>
  9. */
  10. class CompanyProfileFactory extends Factory
  11. {
  12. /**
  13. * @var string The related model's name.
  14. */
  15. protected $model = CompanyProfile::class;
  16. /**
  17. * Define the model's default state.
  18. *
  19. * @return array<string, mixed>
  20. */
  21. public function definition(): array
  22. {
  23. return [
  24. 'address' => $this->faker->streetAddress,
  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. event(new CompanyGenerated($companyProfile->company->owner, $companyProfile->company, $companyProfile->country));
  41. });
  42. }
  43. }