您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

CompanyProfileFactory.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace Database\Factories\Setting;
  3. use App\Enums\Setting\EntityType;
  4. use App\Faker\PhoneNumber;
  5. use App\Faker\State;
  6. use App\Models\Setting\CompanyProfile;
  7. use Illuminate\Database\Eloquent\Factories\Factory;
  8. /**
  9. * @extends Factory<CompanyProfile>
  10. */
  11. class CompanyProfileFactory extends Factory
  12. {
  13. /**
  14. * The name of the factory's corresponding model.
  15. */
  16. protected $model = CompanyProfile::class;
  17. /**
  18. * Define the model's default state.
  19. *
  20. * @return array<string, mixed>
  21. */
  22. public function definition(): array
  23. {
  24. return [
  25. 'address' => $this->faker->streetAddress,
  26. 'zip_code' => $this->faker->postcode,
  27. 'email' => $this->faker->email,
  28. 'entity_type' => $this->faker->randomElement(EntityType::class),
  29. ];
  30. }
  31. public function withCountry(string $code): static
  32. {
  33. /** @var PhoneNumber $phoneFaker */
  34. $phoneFaker = $this->faker;
  35. /** @var State $stateFaker */
  36. $stateFaker = $this->faker;
  37. return $this->state([
  38. 'country' => $code,
  39. 'state_id' => $stateFaker->state($code),
  40. 'phone_number' => $phoneFaker->phoneNumberForCountryCode($code),
  41. ]);
  42. }
  43. }