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.

CompanyProfileFactory.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace Database\Factories\Setting;
  3. use App\Enums\Setting\EntityType;
  4. use App\Faker\State;
  5. use App\Models\Company;
  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. $countryCode = $this->faker->countryCode;
  25. return [
  26. 'address' => $this->faker->streetAddress,
  27. 'zip_code' => $this->faker->postcode,
  28. 'state_id' => $this->faker->state($countryCode),
  29. 'country' => $countryCode,
  30. 'phone_number' => $this->faker->phoneNumberForCountryCode($countryCode),
  31. 'email' => $this->faker->email,
  32. 'entity_type' => $this->faker->randomElement(EntityType::class),
  33. ];
  34. }
  35. public function withCountry(string $code): self
  36. {
  37. return $this->state([
  38. 'country' => $code,
  39. 'state_id' => $this->faker->state($code),
  40. 'phone_number' => $this->faker->phoneNumberForCountryCode($code),
  41. ]);
  42. }
  43. public function forCompany(Company $company): self
  44. {
  45. return $this->state([
  46. 'company_id' => $company->id,
  47. 'created_by' => $company->owner->id,
  48. 'updated_by' => $company->owner->id,
  49. ]);
  50. }
  51. }