UserFactory.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Database\Factories;
  3. use Helpers;
  4. use Illuminate\Database\Eloquent\Factories\Factory;
  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. * Define the model's default state.
  13. *
  14. * @return array<string, mixed>
  15. */
  16. public function definition(): array
  17. {
  18. return [
  19. 'nickname' => fake()->name(),
  20. 'username' => fake()->unique()->safeEmail(),
  21. 'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
  22. 'remember_token' => Str::random(10),
  23. 'port' => Helpers::getPort(),
  24. 'passwd' => Str::random(),
  25. 'vmess_id' => fake()->uuid,
  26. 'method' => Helpers::getDefaultMethod(),
  27. 'protocol' => Helpers::getDefaultProtocol(),
  28. 'obfs' => Helpers::getDefaultObfs(),
  29. 'transfer_enable' => (int) sysConfig('default_traffic') * MiB,
  30. 'expired_at' => date('Y-m-d', strtotime(sysConfig('default_days').' days')),
  31. 'user_group_id' => 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. 'status' => 0,
  41. ]);
  42. }
  43. }