UserFactory.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Database\Factories;
  3. use Illuminate\Database\Eloquent\Factories\Factory;
  4. use Illuminate\Support\Str;
  5. /**
  6. * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
  7. */
  8. class UserFactory extends Factory
  9. {
  10. /**
  11. * Define the model's default state.
  12. *
  13. * @return array<string, mixed>
  14. */
  15. public function definition()
  16. {
  17. return [
  18. 'name' => $this->faker->name(),
  19. 'phone' => $this->faker->phoneNumber(),
  20. 'email' => $this->faker->unique()->safeEmail(),
  21. 'address' => $this->faker->address,
  22. 'email_verified_at' => now(),
  23. 'password' => bcrypt('12345678'),
  24. 'gender_id' => random_int(1, 2),
  25. 'role_id' => random_int(2, 4),
  26. 'outlet_id' => 1,
  27. 'remember_token' => Str::random(10),
  28. ];
  29. }
  30. /**
  31. * Indicate that the model's email address should be unverified.
  32. *
  33. * @return static
  34. */
  35. public function unverified()
  36. {
  37. return $this->state(function (array $attributes) {
  38. return [
  39. 'email_verified_at' => null,
  40. ];
  41. });
  42. }
  43. }