UserFactory.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. 'email' => $this->faker->unique()->safeEmail(),
  20. 'email_verified_at' => now(),
  21. 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
  22. 'remember_token' => Str::random(10),
  23. 'ability' => 'visitor',
  24. ];
  25. }
  26. /**
  27. * Indicate that the model's email address should be unverified.
  28. *
  29. * @return static
  30. */
  31. public function unverified()
  32. {
  33. return $this->state(function (array $attributes) {
  34. return [
  35. 'email_verified_at' => null,
  36. ];
  37. });
  38. }
  39. }