$faker->firstName, 'last_name' => $faker->lastName, 'email' => 'demo@demo.com', 'password' => Hash::make('demo'), 'email_verified_at' => now(), ]); $this->addDummyInfo($faker, $demoUser); $demoUser2 = User::create([ 'first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'email' => 'admin@demo.com', 'password' => Hash::make('demo'), 'email_verified_at' => now(), ]); $this->addDummyInfo($faker, $demoUser2); User::factory(100)->create()->each(function (User $user) use ($faker) { $this->addDummyInfo($faker, $user); }); } private function addDummyInfo(Generator $faker, User $user) { $dummyInfo = [ 'company' => $faker->company, 'phone' => $faker->phoneNumber, 'website' => $faker->url, 'language' => $faker->languageCode, 'country' => $faker->countryCode, ]; $info = new UserInfo(); foreach ($dummyInfo as $key => $value) { $info->$key = $value; } $info->user()->associate($user); $info->save(); } }