UserFactory.php 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. 'password' => bcrypt('12345678'),
  22. 'role_id' => random_int(2, 4),
  23. 'email_verified_at' => now(),
  24. 'remember_token' => Str::random(10),
  25. ];
  26. }
  27. /**
  28. * Indicate that the model's email address should be unverified.
  29. *
  30. * @return static
  31. */
  32. public function unverified()
  33. {
  34. return $this->state(function (array $attributes) {
  35. return [
  36. 'email_verified_at' => null,
  37. ];
  38. });
  39. }
  40. }