Wedding Invitation
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.

UserFactory.php 1.0KB

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