*/ 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 { $first_name = fake()->firstName(); $last_name = fake()->lastName(); return [ 'name' => "$first_name $last_name", 'first_name' => $first_name, 'last_name' => $last_name, 'phone' => fake()->phoneNumber(), 'role' => fake()->randomElement(['STUDENT', 'EMPLOYER', 'ADMIN']), 'email' => fake()->unique()->safeEmail(), 'email_verified_at' => now(), 'password' => static::$password ??= Hash::make('password'), 'remember_token' => Str::random(10), 'active' => true, 'needs_password_change' => false, ]; } /** * Indicate that the model's email address should be unverified. */ public function unverified(): static { return $this->state(fn (array $attributes) => [ 'email_verified_at' => null, ]); } }