fzaninotto / Faker

Faker is a PHP library that generates fake data for you
MIT License
26.8k stars 3.57k forks source link

Data produce identical on for loop #2004

Closed iqmal852 closed 4 years ago

iqmal852 commented 4 years ago

Summary

Picture will be self explain

Versions

Version
PHP 7.3
fzaninotto/faker 1.9.1

Self-enclosed code snippet for reproduction

$faker = Faker\Factory::create();

$entries = [];

$data = [
    "name" => $faker->name,
    "email" => $faker->unique()->safeEmail,
    "email_verified_at" => now(),
    "password" => bcrypt("password"),
    "remember_token" => $faker->name,
    "created_at" => now(),
    "updated_at" => now(),
];

for ($x = 0; $x <= 100; $x++) { 
  $entries[] = $data; 
}

$entries;

Expected output

The output should be different each time looping

Actual output

[
      [
       "name" => "Prof. Deion Huels DVM",
       "email" => "prohaska.brendan@example.com",
       "email_verified_at" => Illuminate\Support\Carbon @1590590664 {#1010},
       "password" => "$2y$10$dqhBGM5mB/CD7E9dJw.ct.cn4uozeOQtjAk./fddHQ9KBOCT1GCZq",
       "remember_token" => "Jevon Krajcik",
       "created_at" => Illuminate\Support\Carbon @1590590664 {#1007},
       "updated_at" => Illuminate\Support\Carbon @1590590664 {#1006},
     ],
     [
       "name" => "Prof. Deion Huels DVM",
       "email" => "prohaska.brendan@example.com",
       "email_verified_at" => Illuminate\Support\Carbon @1590590664 {#1010},
       "password" => "$2y$10$dqhBGM5mB/CD7E9dJw.ct.cn4uozeOQtjAk./fddHQ9KBOCT1GCZq",
       "remember_token" => "Jevon Krajcik",
       "created_at" => Illuminate\Support\Carbon @1590590664 {#1007},
       "updated_at" => Illuminate\Support\Carbon @1590590664 {#1006},
     ],
     [
       "name" => "Prof. Deion Huels DVM",
       "email" => "prohaska.brendan@example.com",
       "email_verified_at" => Illuminate\Support\Carbon @1590590664 {#1010},
       "password" => "$2y$10$dqhBGM5mB/CD7E9dJw.ct.cn4uozeOQtjAk./fddHQ9KBOCT1GCZq",
       "remember_token" => "Jevon Krajcik",
       "created_at" => Illuminate\Support\Carbon @1590590664 {#1007},
       "updated_at" => Illuminate\Support\Carbon @1590590664 {#1006},
     ],
]

Image Attachment Screenshot 2020-05-27 at 10 46 58 PM

iqmal852 commented 4 years ago

Solved!