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.

AddressFactory.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace Database\Factories\Common;
  3. use App\Enums\Common\AddressType;
  4. use App\Models\Common\Address;
  5. use Illuminate\Database\Eloquent\Factories\Factory;
  6. /**
  7. * @extends Factory<Address>
  8. */
  9. class AddressFactory extends Factory
  10. {
  11. /**
  12. * The name of the factory's corresponding model.
  13. */
  14. protected $model = Address::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. 'company_id' => 1,
  24. 'type' => $this->faker->randomElement(AddressType::cases()),
  25. 'recipient' => $this->faker->name,
  26. 'phone' => $this->faker->phoneNumber,
  27. 'address_line_1' => $this->faker->streetAddress,
  28. 'address_line_2' => $this->faker->streetAddress,
  29. 'city' => $this->faker->city,
  30. 'state' => $this->faker->state('US'),
  31. 'postal_code' => $this->faker->postcode,
  32. 'country' => 'US',
  33. 'notes' => $this->faker->sentence,
  34. 'created_by' => 1,
  35. 'updated_by' => 1,
  36. ];
  37. }
  38. public function billing(): self
  39. {
  40. return $this->state([
  41. 'type' => AddressType::Billing,
  42. ]);
  43. }
  44. public function shipping(): self
  45. {
  46. return $this->state([
  47. 'type' => AddressType::Shipping,
  48. ]);
  49. }
  50. public function general(): self
  51. {
  52. return $this->state([
  53. 'type' => AddressType::General,
  54. ]);
  55. }
  56. }