UserFactory.php 798 B

123456789101112131415161718192021222324252627
  1. <?php
  2. use App\User;
  3. use Faker\Generator as Faker;
  4. /*
  5. |--------------------------------------------------------------------------
  6. | Model Factories
  7. |--------------------------------------------------------------------------
  8. |
  9. | This directory should contain each of the model factory definitions for
  10. | your application. Factories provide a convenient way to generate new
  11. | model instances for testing / seeding your application's database.
  12. |
  13. */
  14. /** @var \Illuminate\Database\Eloquent\Factory $factory */
  15. $factory->define(User::class, function (Faker $faker) {
  16. static $password;
  17. return [
  18. 'name' => $faker->name,
  19. 'email' => $faker->unique()->safeEmail,
  20. 'password' => $password ?: $password = bcrypt('secret'),
  21. 'remember_token' => str_random(10),
  22. ];
  23. });