Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ClientFactory.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace Database\Factories\Common;
  3. use App\Models\Common\Address;
  4. use App\Models\Common\Client;
  5. use App\Models\Common\Contact;
  6. use Illuminate\Database\Eloquent\Factories\Factory;
  7. /**
  8. * @extends Factory<Client>
  9. */
  10. class ClientFactory extends Factory
  11. {
  12. /**
  13. * The name of the factory's corresponding model.
  14. */
  15. protected $model = Client::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. 'company_id' => 1,
  25. 'name' => $this->faker->company,
  26. 'currency_code' => 'USD',
  27. 'account_number' => $this->faker->unique()->numerify(str_repeat('#', 12)),
  28. 'website' => $this->faker->url,
  29. 'notes' => $this->faker->sentence,
  30. 'created_by' => 1,
  31. 'updated_by' => 1,
  32. ];
  33. }
  34. public function withContacts(int $count = 1): self
  35. {
  36. return $this->has(Contact::factory()->count($count));
  37. }
  38. public function withPrimaryContact(): self
  39. {
  40. return $this->has(Contact::factory()->primary());
  41. }
  42. public function withAddresses(): self
  43. {
  44. return $this
  45. ->has(Address::factory()->billing())
  46. ->has(Address::factory()->shipping());
  47. }
  48. }