*/ class UserFactory extends Factory { /** * The current password being used by the factory. */ protected static ?string $password; /** * Define the model's default state. * * @return array */ public function definition(): array { return [ 'first_name' => fake()->firstName(), 'last_name' => fake()->lastName(), 'email' => fake()->unique()->safeEmail(), 'email_verified_at' => now(), 'password' => static::$password ??= Hash::make('password'), 'phone' => fake()->phoneNumber(), 'date_of_birth' => fake()->date('Y-m-d', '2000-01-01'), 'gender' => fake()->randomElement(['male', 'female', 'other', 'prefer_not_to_say']), 'bio' => fake()->paragraph(3), 'website' => fake()->url(), 'linkedin' => 'https://linkedin.com/in/' . fake()->userName(), 'github' => 'https://github.com/' . fake()->userName(), 'twitter' => 'https://twitter.com/' . fake()->userName(), 'preferences' => [ 'theme' => fake()->randomElement(['professional', 'modern', 'minimal']), 'language' => fake()->randomElement(['en', 'de', 'es', 'fr']), 'notifications' => fake()->boolean(), 'marketing_emails' => fake()->boolean(), ], 'newsletter_subscribed' => fake()->boolean(), 'last_login_at' => fake()->optional()->dateTimeBetween('-1 month', 'now'), 'last_login_ip' => fake()->ipv4(), 'status' => fake()->randomElement(['active', 'inactive']), 'locale' => fake()->randomElement(['en', 'de', 'es', 'fr']), 'timezone' => fake()->timezone(), 'profile_completed_at' => fake()->optional(0.8)->dateTimeBetween('-1 month', 'now'), 'remember_token' => Str::random(10), ]; } /** * Indicate that the model's email address should be unverified. */ public function unverified() { return $this->state(function (array $attributes) { return [ 'email_verified_at' => null, ]; }); } /** * Indicate that the user is suspended. */ public function suspended() { return $this->state(function (array $attributes) { return [ 'status' => 'suspended', 'suspended_at' => now(), 'suspension_reason' => fake()->sentence(), ]; }); } /** * Indicate that the user has incomplete profile. */ public function incompleteProfile() { return $this->state(function (array $attributes) { return [ 'profile_completed_at' => null, 'bio' => null, 'website' => null, 'phone' => null, ]; }); } }