*/ 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 [ 'username' => fake()->userName(), 'email' => fake()->unique()->safeEmail(), 'password' => static::$password ??= Hash::make('password'), ]; } /** * Configure the model factory. */ public function configure(): static { return $this->afterCreating(function (User $user) { $user->profile()->create([ 'nik' => fake()->numerify('################'), 'full_name' => fake()->name(), 'phone_number' => fake()->phoneNumber(), 'address' => fake()->address(), 'birth_place' => fake()->city(), 'birth_date' => fake()->date(), ]); }); } }