AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

UserFactory.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace Database\Factories;
  3. use App\Models\User;
  4. use Illuminate\Database\Eloquent\Factories\Factory;
  5. use Illuminate\Support\Facades\Hash;
  6. use Illuminate\Support\Str;
  7. /**
  8. * @extends Factory<User>
  9. */
  10. class UserFactory extends Factory
  11. {
  12. /**
  13. * The current password being used by the factory.
  14. */
  15. protected static ?string $password;
  16. /**
  17. * Define the model's default state.
  18. *
  19. * @return array<string, mixed>
  20. */
  21. public function definition(): array
  22. {
  23. return [
  24. 'name' => fake()->name(),
  25. 'email' => fake()->unique()->safeEmail(),
  26. 'email_verified_at' => now(),
  27. 'password' => static::$password ??= Hash::make('password'),
  28. 'remember_token' => Str::random(10),
  29. 'two_factor_secret' => null,
  30. 'two_factor_recovery_codes' => null,
  31. 'two_factor_confirmed_at' => null,
  32. ];
  33. }
  34. /**
  35. * Indicate that the model's email address should be unverified.
  36. */
  37. public function unverified(): static
  38. {
  39. return $this->state(fn (array $attributes) => [
  40. 'email_verified_at' => null,
  41. ]);
  42. }
  43. /**
  44. * Indicate that the model has two-factor authentication configured.
  45. */
  46. public function withTwoFactor(): static
  47. {
  48. return $this->state(fn (array $attributes) => [
  49. 'two_factor_secret' => encrypt('secret'),
  50. 'two_factor_recovery_codes' => encrypt(json_encode(['recovery-code-1'])),
  51. 'two_factor_confirmed_at' => now(),
  52. ]);
  53. }
  54. }