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.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Database\Factories\Setting;
  3. use App\Enums\Setting\EntityType;
  4. use App\Faker\State;
  5. use App\Models\Common\Address;
  6. use App\Models\Company;
  7. use App\Models\Setting\CompanyProfile;
  8. use Illuminate\Database\Eloquent\Factories\Factory;
  9. /**
  10. * @extends Factory<CompanyProfile>
  11. */
  12. class CompanyProfileFactory extends Factory
  13. {
  14. /**
  15. * The name of the factory's corresponding model.
  16. */
  17. protected $model = CompanyProfile::class;
  18. /**
  19. * Define the model's default state.
  20. *
  21. * @return array<string, mixed>
  22. */
  23. public function definition(): array
  24. {
  25. return [
  26. 'phone_number' => $this->faker->phoneNumber,
  27. 'email' => $this->faker->email,
  28. 'entity_type' => $this->faker->randomElement(EntityType::class),
  29. ];
  30. }
  31. public function forCompany(Company $company): self
  32. {
  33. return $this->state([
  34. 'company_id' => $company->id,
  35. 'created_by' => $company->owner->id,
  36. 'updated_by' => $company->owner->id,
  37. ]);
  38. }
  39. public function withAddress(): self
  40. {
  41. return $this->has(Address::factory()->general());
  42. }
  43. }